3 * A lock-free somewhat-queue that doesn't
4 * require hazard pointers.
6 * (C) Copyright 2011 Xamarin Inc.
7 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
9 #ifndef __MONO_LOCK_FREE_ARRAY_QUEUE_H__
10 #define __MONO_LOCK_FREE_ARRAY_QUEUE_H__
13 #include <mono/utils/mono-compiler.h>
14 #include <mono/utils/mono-mmap.h>
16 typedef struct _MonoLockFreeArrayChunk MonoLockFreeArrayChunk
;
20 MonoLockFreeArrayChunk
*chunk_list
;
21 MonoMemAccountType account_type
;
25 MonoLockFreeArray array
;
26 gint32 num_used_entries
;
27 } MonoLockFreeArrayQueue
;
29 #define MONO_LOCK_FREE_ARRAY_INIT(entry_size, account_type) { (entry_size), NULL, (account_type) }
30 #define MONO_LOCK_FREE_ARRAY_QUEUE_INIT(entry_size, account_type) { MONO_LOCK_FREE_ARRAY_INIT ((entry_size) + sizeof (gpointer), (account_type)), 0 }
32 gpointer
mono_lock_free_array_nth (MonoLockFreeArray
*arr
, int index
);
34 typedef gpointer (*MonoLockFreeArrayIterateFunc
) (int index
, gpointer entry_ptr
, gpointer user_data
);
35 gpointer
mono_lock_free_array_iterate (MonoLockFreeArray
*arr
, MonoLockFreeArrayIterateFunc func
, gpointer user_data
);
37 void mono_lock_free_array_cleanup (MonoLockFreeArray
*arr
);
39 void mono_lock_free_array_queue_push (MonoLockFreeArrayQueue
*q
, gpointer entry_data_ptr
);
40 gboolean
mono_lock_free_array_queue_pop (MonoLockFreeArrayQueue
*q
, gpointer entry_data_ptr
);
42 void mono_lock_free_array_queue_cleanup (MonoLockFreeArrayQueue
*q
);