2 * lock-free-array-queue.h: A lock-free somewhat-queue that doesn't
3 * require hazard pointers.
5 * (C) Copyright 2011 Xamarin Inc.
7 #ifndef __MONO_LOCK_FREE_ARRAY_QUEUE_H__
8 #define __MONO_LOCK_FREE_ARRAY_QUEUE_H__
11 #include <mono/utils/mono-compiler.h>
13 typedef struct _MonoLockFreeArrayChunk MonoLockFreeArrayChunk;
17 MonoLockFreeArrayChunk *chunk_list;
21 MonoLockFreeArray array;
22 gint32 num_used_entries;
23 } MonoLockFreeArrayQueue;
25 #define MONO_LOCK_FREE_ARRAY_INIT(entry_size) { (entry_size), NULL }
26 #define MONO_LOCK_FREE_ARRAY_QUEUE_INIT(entry_size) { MONO_LOCK_FREE_ARRAY_INIT ((entry_size) + sizeof (gpointer)), 0 }
28 gpointer mono_lock_free_array_nth (MonoLockFreeArray *arr, int index) MONO_INTERNAL;
30 typedef gpointer (*MonoLockFreeArrayIterateFunc) (int index, gpointer entry_ptr, gpointer user_data);
31 gpointer mono_lock_free_array_iterate (MonoLockFreeArray *arr, MonoLockFreeArrayIterateFunc func, gpointer user_data) MONO_INTERNAL;
33 void mono_lock_free_array_cleanup (MonoLockFreeArray *arr) MONO_INTERNAL;
35 void mono_lock_free_array_queue_push (MonoLockFreeArrayQueue *q, gpointer entry_data_ptr) MONO_INTERNAL;
36 gboolean mono_lock_free_array_queue_pop (MonoLockFreeArrayQueue *q, gpointer entry_data_ptr) MONO_INTERNAL;
38 void mono_lock_free_array_queue_cleanup (MonoLockFreeArrayQueue *q) MONO_INTERNAL;