Update Haiku support (#15674)
[mono-project.git] / mono / utils / lock-free-array-queue.h
blobe23754d6a251041b4629c8395d63c83f5d16123a
1 /**
2 * \file
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.
8 */
9 #ifndef __MONO_LOCK_FREE_ARRAY_QUEUE_H__
10 #define __MONO_LOCK_FREE_ARRAY_QUEUE_H__
12 #include <glib.h>
13 #include <mono/utils/mono-compiler.h>
14 #include <mono/utils/mono-mmap.h>
16 typedef struct _MonoLockFreeArrayChunk MonoLockFreeArrayChunk;
18 typedef struct {
19 size_t entry_size;
20 MonoLockFreeArrayChunk *chunk_list;
21 MonoMemAccountType account_type;
22 } MonoLockFreeArray;
24 typedef struct {
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);
44 #endif