2 * lock-free-array-queue.h: A lock-free somewhat-queue that doesn't
3 * require hazard pointers.
5 * (C) Copyright 2011 Xamarin Inc.
6 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
8 #ifndef __MONO_LOCK_FREE_ARRAY_QUEUE_H__
9 #define __MONO_LOCK_FREE_ARRAY_QUEUE_H__
12 #include <mono/utils/mono-compiler.h>
13 #include <mono/utils/mono-mmap.h>
15 typedef struct _MonoLockFreeArrayChunk MonoLockFreeArrayChunk;
19 MonoLockFreeArrayChunk *chunk_list;
20 MonoMemAccountType account_type;
24 MonoLockFreeArray array;
25 gint32 num_used_entries;
26 } MonoLockFreeArrayQueue;
28 #define MONO_LOCK_FREE_ARRAY_INIT(entry_size, account_type) { (entry_size), NULL, (account_type) }
29 #define MONO_LOCK_FREE_ARRAY_QUEUE_INIT(entry_size, account_type) { MONO_LOCK_FREE_ARRAY_INIT ((entry_size) + sizeof (gpointer), (account_type)), 0 }
31 gpointer mono_lock_free_array_nth (MonoLockFreeArray *arr, int index);
33 typedef gpointer (*MonoLockFreeArrayIterateFunc) (int index, gpointer entry_ptr, gpointer user_data);
34 gpointer mono_lock_free_array_iterate (MonoLockFreeArray *arr, MonoLockFreeArrayIterateFunc func, gpointer user_data);
36 void mono_lock_free_array_cleanup (MonoLockFreeArray *arr);
38 void mono_lock_free_array_queue_push (MonoLockFreeArrayQueue *q, gpointer entry_data_ptr);
39 gboolean mono_lock_free_array_queue_pop (MonoLockFreeArrayQueue *q, gpointer entry_data_ptr);
41 void mono_lock_free_array_queue_cleanup (MonoLockFreeArrayQueue *q);