rculfhash: make cds_lfht_iter_get_node argument const
[userspace-rcu.git] / include / urcu / wfqueue.h
1 // SPDX-FileCopyrightText: 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4
5 #ifndef _URCU_WFQUEUE_H
6 #define _URCU_WFQUEUE_H
7
8 /*
9 * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue
10 */
11
12 #include <pthread.h>
13 #include <urcu/compiler.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #ifndef CDS_WFQ_DEPRECATED
20 #define CDS_WFQ_DEPRECATED \
21 CDS_DEPRECATED("urcu/wfqueue.h is deprecated. Please use urcu/wfcqueue.h instead.")
22 #endif
23
24 /*
25 * Queue with wait-free enqueue/blocking dequeue.
26 * This implementation adds a dummy head node when the queue is empty to ensure
27 * we can always update the queue locklessly.
28 *
29 * Inspired from half-wait-free/half-blocking queue implementation done by
30 * Paul E. McKenney.
31 */
32
33 struct cds_wfq_node {
34 struct cds_wfq_node *next;
35 };
36
37 struct cds_wfq_queue {
38 struct cds_wfq_node *head, **tail;
39 struct cds_wfq_node dummy; /* Dummy node */
40 pthread_mutex_t lock;
41 };
42
43 #ifdef _LGPL_SOURCE
44
45 #include <urcu/static/wfqueue.h>
46
47 static inline CDS_WFQ_DEPRECATED
48 void cds_wfq_node_init(struct cds_wfq_node *node)
49 {
50 _cds_wfq_node_init(node);
51 }
52
53 static inline CDS_WFQ_DEPRECATED
54 void cds_wfq_init(struct cds_wfq_queue *q)
55 {
56 _cds_wfq_init(q);
57 }
58
59 static inline CDS_WFQ_DEPRECATED
60 void cds_wfq_destroy(struct cds_wfq_queue *q)
61 {
62 _cds_wfq_destroy(q);
63 }
64
65 static inline CDS_WFQ_DEPRECATED
66 void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node)
67 {
68 _cds_wfq_enqueue(q, node);
69 }
70
71 static inline CDS_WFQ_DEPRECATED
72 struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
73 {
74 return ___cds_wfq_dequeue_blocking(q);
75 }
76
77 static inline CDS_WFQ_DEPRECATED
78 struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
79 {
80 return _cds_wfq_dequeue_blocking(q);
81 }
82
83 #else /* !_LGPL_SOURCE */
84
85 extern CDS_WFQ_DEPRECATED
86 void cds_wfq_node_init(struct cds_wfq_node *node);
87
88 extern CDS_WFQ_DEPRECATED
89 void cds_wfq_init(struct cds_wfq_queue *q);
90
91 extern CDS_WFQ_DEPRECATED
92 void cds_wfq_destroy(struct cds_wfq_queue *q);
93
94 extern CDS_WFQ_DEPRECATED
95 void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node);
96
97 /* __cds_wfq_dequeue_blocking: caller ensures mutual exclusion between dequeues */
98 extern CDS_WFQ_DEPRECATED
99 struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
100
101 extern CDS_WFQ_DEPRECATED
102 struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
103
104 #endif /* !_LGPL_SOURCE */
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif /* _URCU_WFQUEUE_H */
This page took 0.056686 seconds and 4 git commands to generate.