Add CMM memory model
[urcu.git] / include / urcu / wfcqueue.h
CommitLineData
d3d3857f
MJ
1// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2// SPDX-FileCopyrightText: 2011-2012 Lai Jiangshan <laijs@cn.fujitsu.com>
3//
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
8ad4ce58
MD
6#ifndef _URCU_WFCQUEUE_H
7#define _URCU_WFCQUEUE_H
8
9/*
8ad4ce58 10 * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue
8ad4ce58
MD
11 */
12
13#include <pthread.h>
8ad4ce58
MD
14#include <stdbool.h>
15#include <urcu/compiler.h>
16#include <urcu/arch.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/*
23 * Concurrent queue with wait-free enqueue/blocking dequeue.
24 *
ebfd2673
MD
25 * This queue has been designed and implemented collaboratively by
26 * Mathieu Desnoyers and Lai Jiangshan. Inspired from
27 * half-wait-free/half-blocking queue implementation done by Paul E.
28 * McKenney.
8ad4ce58
MD
29 */
30
0b73c819 31#define CDS_WFCQ_WOULDBLOCK ((struct cds_wfcq_node *) -1UL)
47215721 32
23773356 33enum cds_wfcq_ret {
f878b49e 34 CDS_WFCQ_RET_WOULDBLOCK = -1,
23773356
MD
35 CDS_WFCQ_RET_DEST_EMPTY = 0,
36 CDS_WFCQ_RET_DEST_NON_EMPTY = 1,
37 CDS_WFCQ_RET_SRC_EMPTY = 2,
38};
39
eec791af
MD
40enum cds_wfcq_state {
41 CDS_WFCQ_STATE_LAST = (1U << 0),
42};
43
8ad4ce58
MD
44struct cds_wfcq_node {
45 struct cds_wfcq_node *next;
46};
47
48/*
49 * Do not put head and tail on the same cache-line if concurrent
50 * enqueue/dequeue are expected from many CPUs. This eliminates
51 * false-sharing between enqueue and dequeue.
52 */
f637f191
MD
53struct __cds_wfcq_head {
54 struct cds_wfcq_node node;
55};
56
8ad4ce58
MD
57struct cds_wfcq_head {
58 struct cds_wfcq_node node;
59 pthread_mutex_t lock;
60};
61
f637f191 62/*
0cdbb569 63 * In C, the transparent union allows calling functions that work on both
f637f191
MD
64 * struct cds_wfcq_head and struct __cds_wfcq_head on any of those two
65 * types.
0cdbb569
MD
66 *
67 * In C++, implement static inline wrappers using function overloading
68 * to obtain an API similar to C.
087bce43
MD
69 *
70 * Avoid complaints from clang++ not knowing the transparent union
71 * attribute.
f637f191 72 */
087bce43
MD
73#if defined(__clang__)
74#pragma clang diagnostic push
75#pragma clang diagnostic ignored "-Wignored-attributes"
76#endif
5135c0fd 77typedef union {
f637f191
MD
78 struct __cds_wfcq_head *_h;
79 struct cds_wfcq_head *h;
087bce43
MD
80} __attribute__((__transparent_union__)) cds_wfcq_head_ptr_t;
81#if defined(__clang__)
82#pragma clang diagnostic pop
83#endif
f637f191 84
0cdbb569 85#ifndef __cplusplus
4d0d7cbc
MD
86/*
87 * This static inline is only present for compatibility with C++. It is
88 * effect-less in C.
89 */
90static inline struct __cds_wfcq_head *__cds_wfcq_head_cast(struct __cds_wfcq_head *head)
91{
92 return head;
93}
94
95/*
96 * This static inline is only present for compatibility with C++. It is
97 * effect-less in C.
98 */
99static inline struct cds_wfcq_head *cds_wfcq_head_cast(struct cds_wfcq_head *head)
100{
101 return head;
102}
103#else /* #ifndef __cplusplus */
104
0cdbb569 105/*
aaf0064b
MD
106 * This static inline is used by internally in the static inline
107 * implementation of the API.
0cdbb569 108 */
4d0d7cbc
MD
109static inline cds_wfcq_head_ptr_t __cds_wfcq_head_cast(struct __cds_wfcq_head *head)
110{
111 cds_wfcq_head_ptr_t ret = { ._h = head };
112 return ret;
113}
0cdbb569
MD
114
115/*
aaf0064b
MD
116 * This static inline is used by internally in the static inline
117 * implementation of the API.
0cdbb569 118 */
4d0d7cbc
MD
119static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast(struct cds_wfcq_head *head)
120{
121 cds_wfcq_head_ptr_t ret = { .h = head };
122 return ret;
123}
124#endif /* #else #ifndef __cplusplus */
125
8ad4ce58
MD
126struct cds_wfcq_tail {
127 struct cds_wfcq_node *p;
128};
129
130#ifdef _LGPL_SOURCE
131
132#include <urcu/static/wfcqueue.h>
133
134#define cds_wfcq_node_init _cds_wfcq_node_init
135#define cds_wfcq_init _cds_wfcq_init
b4edfa81 136#define __cds_wfcq_init ___cds_wfcq_init
200d100e 137#define cds_wfcq_destroy _cds_wfcq_destroy
8ad4ce58
MD
138#define cds_wfcq_empty _cds_wfcq_empty
139#define cds_wfcq_enqueue _cds_wfcq_enqueue
140
141/* Dequeue locking */
142#define cds_wfcq_dequeue_lock _cds_wfcq_dequeue_lock
143#define cds_wfcq_dequeue_unlock _cds_wfcq_dequeue_unlock
144
145/* Locking performed within cds_wfcq calls. */
146#define cds_wfcq_dequeue_blocking _cds_wfcq_dequeue_blocking
eec791af
MD
147#define cds_wfcq_dequeue_with_state_blocking \
148 _cds_wfcq_dequeue_with_state_blocking
8ad4ce58
MD
149#define cds_wfcq_splice_blocking _cds_wfcq_splice_blocking
150#define cds_wfcq_first_blocking _cds_wfcq_first_blocking
151#define cds_wfcq_next_blocking _cds_wfcq_next_blocking
152
153/* Locking ensured by caller by holding cds_wfcq_dequeue_lock() */
154#define __cds_wfcq_dequeue_blocking ___cds_wfcq_dequeue_blocking
eec791af
MD
155#define __cds_wfcq_dequeue_with_state_blocking \
156 ___cds_wfcq_dequeue_with_state_blocking
8ad4ce58
MD
157#define __cds_wfcq_splice_blocking ___cds_wfcq_splice_blocking
158#define __cds_wfcq_first_blocking ___cds_wfcq_first_blocking
159#define __cds_wfcq_next_blocking ___cds_wfcq_next_blocking
160
47215721
MD
161/*
162 * Locking ensured by caller by holding cds_wfcq_dequeue_lock().
163 * Non-blocking: deque, first, next return CDS_WFCQ_WOULDBLOCK if they
164 * need to block. splice returns nonzero if it needs to block.
165 */
166#define __cds_wfcq_dequeue_nonblocking ___cds_wfcq_dequeue_nonblocking
eec791af
MD
167#define __cds_wfcq_dequeue_with_state_nonblocking \
168 ___cds_wfcq_dequeue_with_state_nonblocking
47215721
MD
169#define __cds_wfcq_splice_nonblocking ___cds_wfcq_splice_nonblocking
170#define __cds_wfcq_first_nonblocking ___cds_wfcq_first_nonblocking
171#define __cds_wfcq_next_nonblocking ___cds_wfcq_next_nonblocking
172
8ad4ce58
MD
173#else /* !_LGPL_SOURCE */
174
175/*
176 * Mutual exclusion of cds_wfcq_* / __cds_wfcq_* API
177 *
f878b49e
MD
178 * Synchronization table:
179 *
180 * External synchronization techniques described in the API below is
181 * required between pairs marked with "X". No external synchronization
182 * required between pairs marked with "-".
183 *
184 * Legend:
185 * [1] cds_wfcq_enqueue
186 * [2] __cds_wfcq_splice (destination queue)
187 * [3] __cds_wfcq_dequeue
188 * [4] __cds_wfcq_splice (source queue)
189 * [5] __cds_wfcq_first
190 * [6] __cds_wfcq_next
191 *
192 * [1] [2] [3] [4] [5] [6]
193 * [1] - - - - - -
194 * [2] - - - - - -
195 * [3] - - X X X X
196 * [4] - - X - X X
197 * [5] - - X X - -
198 * [6] - - X X - -
199 *
8ad4ce58
MD
200 * Mutual exclusion can be ensured by holding cds_wfcq_dequeue_lock().
201 *
202 * For convenience, cds_wfcq_dequeue_blocking() and
203 * cds_wfcq_splice_blocking() hold the dequeue lock.
1fe734e1
MD
204 *
205 * Besides locking, mutual exclusion of dequeue, splice and iteration
206 * can be ensured by performing all of those operations from a single
207 * thread, without requiring any lock.
8ad4ce58
MD
208 */
209
210/*
211 * cds_wfcq_node_init: initialize wait-free queue node.
212 */
213extern void cds_wfcq_node_init(struct cds_wfcq_node *node);
214
215/*
200d100e
MD
216 * cds_wfcq_init: initialize wait-free queue. Pair with
217 * cds_wfcq_destroy().
8ad4ce58
MD
218 */
219extern void cds_wfcq_init(struct cds_wfcq_head *head,
220 struct cds_wfcq_tail *tail);
221
f637f191 222/*
200d100e
MD
223 * cds_wfcq_destroy: destroy wait-free queue. Pair with
224 * cds_wfcq_init().
225 */
226extern void cds_wfcq_destroy(struct cds_wfcq_head *head,
227 struct cds_wfcq_tail *tail);
228
229/*
230 * __cds_wfcq_init: initialize wait-free queue (without lock). Don't
231 * pair with any destroy function.
f637f191
MD
232 */
233extern void __cds_wfcq_init(struct __cds_wfcq_head *head,
234 struct cds_wfcq_tail *tail);
235
8ad4ce58
MD
236/*
237 * cds_wfcq_empty: return whether wait-free queue is empty.
238 *
239 * No memory barrier is issued. No mutual exclusion is required.
240 */
f637f191 241extern bool cds_wfcq_empty(cds_wfcq_head_ptr_t head,
8ad4ce58
MD
242 struct cds_wfcq_tail *tail);
243
244/*
245 * cds_wfcq_dequeue_lock: take the dequeue mutual exclusion lock.
246 */
247extern void cds_wfcq_dequeue_lock(struct cds_wfcq_head *head,
248 struct cds_wfcq_tail *tail);
249
250/*
251 * cds_wfcq_dequeue_unlock: release the dequeue mutual exclusion lock.
252 */
253extern void cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head,
254 struct cds_wfcq_tail *tail);
255
256/*
257 * cds_wfcq_enqueue: enqueue a node into a wait-free queue.
258 *
259 * Issues a full memory barrier before enqueue. No mutual exclusion is
260 * required.
23773356
MD
261 *
262 * Returns false if the queue was empty prior to adding the node.
263 * Returns true otherwise.
8ad4ce58 264 */
f637f191 265extern bool cds_wfcq_enqueue(cds_wfcq_head_ptr_t head,
8ad4ce58
MD
266 struct cds_wfcq_tail *tail,
267 struct cds_wfcq_node *node);
268
269/*
270 * cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue.
271 *
272 * Content written into the node before enqueue is guaranteed to be
273 * consistent, but no other memory ordering is ensured.
274 * It is valid to reuse and free a dequeued node immediately.
ffa11a18 275 * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is
1fe734e1 276 * ensured.
8ad4ce58
MD
277 */
278extern struct cds_wfcq_node *cds_wfcq_dequeue_blocking(
279 struct cds_wfcq_head *head,
280 struct cds_wfcq_tail *tail);
281
eec791af
MD
282/*
283 * cds_wfcq_dequeue_with_state_blocking: dequeue with state.
284 *
285 * Same as cds_wfcq_dequeue_blocking, but saves whether dequeueing the
286 * last node of the queue into state (CDS_WFCQ_STATE_LAST).
287 */
288extern struct cds_wfcq_node *cds_wfcq_dequeue_with_state_blocking(
289 struct cds_wfcq_head *head,
290 struct cds_wfcq_tail *tail,
291 int *state);
292
8ad4ce58
MD
293/*
294 * cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q.
295 *
296 * Dequeue all nodes from src_q.
297 * dest_q must be already initialized.
298 * Content written into the node before enqueue is guaranteed to be
299 * consistent, but no other memory ordering is ensured.
ffa11a18 300 * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is
1fe734e1 301 * ensured.
23773356
MD
302 *
303 * Returns enum cds_wfcq_ret which indicates the state of the src or
b94aaf6f 304 * dest queue.
8ad4ce58 305 */
23773356 306extern enum cds_wfcq_ret cds_wfcq_splice_blocking(
8ad4ce58
MD
307 struct cds_wfcq_head *dest_q_head,
308 struct cds_wfcq_tail *dest_q_tail,
309 struct cds_wfcq_head *src_q_head,
310 struct cds_wfcq_tail *src_q_tail);
311
312/*
47215721 313 * __cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue.
8ad4ce58
MD
314 *
315 * Content written into the node before enqueue is guaranteed to be
316 * consistent, but no other memory ordering is ensured.
317 * It is valid to reuse and free a dequeued node immediately.
1fe734e1
MD
318 * Dequeue/splice/iteration mutual exclusion should be ensured by the
319 * caller.
8ad4ce58
MD
320 */
321extern struct cds_wfcq_node *__cds_wfcq_dequeue_blocking(
f637f191 322 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
323 struct cds_wfcq_tail *tail);
324
eec791af
MD
325/*
326 * __cds_wfcq_dequeue_with_state_blocking: dequeue with state.
327 *
328 * Same as __cds_wfcq_dequeue_blocking, but saves whether dequeueing the
329 * last node of the queue into state (CDS_WFCQ_STATE_LAST).
330 */
331extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking(
f637f191 332 cds_wfcq_head_ptr_t head,
eec791af
MD
333 struct cds_wfcq_tail *tail,
334 int *state);
335
47215721
MD
336/*
337 * __cds_wfcq_dequeue_nonblocking: dequeue a node from a wait-free queue.
338 *
339 * Same as __cds_wfcq_dequeue_blocking, but returns CDS_WFCQ_WOULDBLOCK
340 * if it needs to block.
341 */
342extern struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking(
f637f191 343 cds_wfcq_head_ptr_t head,
47215721
MD
344 struct cds_wfcq_tail *tail);
345
eec791af
MD
346/*
347 * __cds_wfcq_dequeue_with_state_blocking: dequeue with state.
348 *
349 * Same as __cds_wfcq_dequeue_nonblocking, but saves whether dequeueing
350 * the last node of the queue into state (CDS_WFCQ_STATE_LAST).
351 */
352extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking(
f637f191 353 cds_wfcq_head_ptr_t head,
eec791af
MD
354 struct cds_wfcq_tail *tail,
355 int *state);
356
8ad4ce58
MD
357/*
358 * __cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q.
359 *
360 * Dequeue all nodes from src_q.
361 * dest_q must be already initialized.
f878b49e
MD
362 * Mutual exclusion for src_q should be ensured by the caller as
363 * specified in the "Synchronisation table".
23773356 364 * Returns enum cds_wfcq_ret which indicates the state of the src or
f878b49e 365 * dest queue. Never returns CDS_WFCQ_RET_WOULDBLOCK.
8ad4ce58 366 */
23773356 367extern enum cds_wfcq_ret __cds_wfcq_splice_blocking(
f637f191 368 cds_wfcq_head_ptr_t dest_q_head,
8ad4ce58 369 struct cds_wfcq_tail *dest_q_tail,
f637f191 370 cds_wfcq_head_ptr_t src_q_head,
8ad4ce58
MD
371 struct cds_wfcq_tail *src_q_tail);
372
47215721
MD
373/*
374 * __cds_wfcq_splice_nonblocking: enqueue all src_q nodes at the end of dest_q.
375 *
23773356
MD
376 * Same as __cds_wfcq_splice_blocking, but returns
377 * CDS_WFCQ_RET_WOULDBLOCK if it needs to block.
47215721 378 */
23773356 379extern enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
f637f191 380 cds_wfcq_head_ptr_t dest_q_head,
47215721 381 struct cds_wfcq_tail *dest_q_tail,
f637f191 382 cds_wfcq_head_ptr_t src_q_head,
47215721
MD
383 struct cds_wfcq_tail *src_q_tail);
384
8ad4ce58
MD
385/*
386 * __cds_wfcq_first_blocking: get first node of a queue, without dequeuing.
387 *
388 * Content written into the node before enqueue is guaranteed to be
389 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
390 * Dequeue/splice/iteration mutual exclusion should be ensured by the
391 * caller.
f94061a3
MD
392 *
393 * Used by for-like iteration macros:
394 * __cds_wfcq_for_each_blocking()
395 * __cds_wfcq_for_each_blocking_safe()
131a29a6
MD
396 *
397 * Returns NULL if queue is empty, first node otherwise.
8ad4ce58
MD
398 */
399extern struct cds_wfcq_node *__cds_wfcq_first_blocking(
f637f191 400 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
401 struct cds_wfcq_tail *tail);
402
47215721
MD
403/*
404 * __cds_wfcq_first_nonblocking: get first node of a queue, without dequeuing.
405 *
406 * Same as __cds_wfcq_first_blocking, but returns CDS_WFCQ_WOULDBLOCK if
407 * it needs to block.
408 */
409extern struct cds_wfcq_node *__cds_wfcq_first_nonblocking(
f637f191 410 cds_wfcq_head_ptr_t head,
47215721
MD
411 struct cds_wfcq_tail *tail);
412
8ad4ce58
MD
413/*
414 * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing.
415 *
416 * Content written into the node before enqueue is guaranteed to be
417 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
418 * Dequeue/splice/iteration mutual exclusion should be ensured by the
419 * caller.
f94061a3
MD
420 *
421 * Used by for-like iteration macros:
422 * __cds_wfcq_for_each_blocking()
423 * __cds_wfcq_for_each_blocking_safe()
131a29a6
MD
424 *
425 * Returns NULL if reached end of queue, non-NULL next queue node
426 * otherwise.
8ad4ce58
MD
427 */
428extern struct cds_wfcq_node *__cds_wfcq_next_blocking(
f637f191 429 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
430 struct cds_wfcq_tail *tail,
431 struct cds_wfcq_node *node);
432
47215721
MD
433/*
434 * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing.
435 *
436 * Same as __cds_wfcq_next_blocking, but returns CDS_WFCQ_WOULDBLOCK if
437 * it needs to block.
438 */
439extern struct cds_wfcq_node *__cds_wfcq_next_nonblocking(
f637f191 440 cds_wfcq_head_ptr_t head,
47215721
MD
441 struct cds_wfcq_tail *tail,
442 struct cds_wfcq_node *node);
443
8ad4ce58
MD
444#endif /* !_LGPL_SOURCE */
445
446/*
447 * __cds_wfcq_for_each_blocking: Iterate over all nodes in a queue,
448 * without dequeuing them.
f637f191 449 * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer).
8ad4ce58
MD
450 * @tail: tail of the queue (struct cds_wfcq_tail pointer).
451 * @node: iterator on the queue (struct cds_wfcq_node pointer).
452 *
453 * Content written into each node before enqueue is guaranteed to be
454 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
455 * Dequeue/splice/iteration mutual exclusion should be ensured by the
456 * caller.
8ad4ce58
MD
457 */
458#define __cds_wfcq_for_each_blocking(head, tail, node) \
459 for (node = __cds_wfcq_first_blocking(head, tail); \
460 node != NULL; \
461 node = __cds_wfcq_next_blocking(head, tail, node))
462
463/*
464 * __cds_wfcq_for_each_blocking_safe: Iterate over all nodes in a queue,
465 * without dequeuing them. Safe against deletion.
f637f191 466 * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer).
8ad4ce58
MD
467 * @tail: tail of the queue (struct cds_wfcq_tail pointer).
468 * @node: iterator on the queue (struct cds_wfcq_node pointer).
469 * @n: struct cds_wfcq_node pointer holding the next pointer (used
470 * internally).
471 *
472 * Content written into each node before enqueue is guaranteed to be
473 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
474 * Dequeue/splice/iteration mutual exclusion should be ensured by the
475 * caller.
8ad4ce58
MD
476 */
477#define __cds_wfcq_for_each_blocking_safe(head, tail, node, n) \
478 for (node = __cds_wfcq_first_blocking(head, tail), \
479 n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL); \
480 node != NULL; \
481 node = n, n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL))
482
483#ifdef __cplusplus
484}
0cdbb569
MD
485
486/*
487 * In C++, implement static inline wrappers using function overloading
488 * to obtain an API similar to C.
489 */
490
aaf0064b
MD
491static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct __cds_wfcq_head *head)
492{
493 cds_wfcq_head_ptr_t ret = { ._h = head };
494 return ret;
495}
496
497static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct cds_wfcq_head *head)
498{
499 cds_wfcq_head_ptr_t ret = { .h = head };
500 return ret;
501}
502
ee990cac 503template<typename T> static inline bool cds_wfcq_empty(T head,
0cdbb569
MD
504 struct cds_wfcq_tail *tail)
505{
aaf0064b 506 return cds_wfcq_empty(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
507}
508
ee990cac 509template<typename T> static inline bool cds_wfcq_enqueue(T head,
0cdbb569
MD
510 struct cds_wfcq_tail *tail,
511 struct cds_wfcq_node *node)
512{
aaf0064b 513 return cds_wfcq_enqueue(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
514}
515
ee990cac
MD
516template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_dequeue_blocking(
517 T head, struct cds_wfcq_tail *tail)
0cdbb569 518{
aaf0064b 519 return __cds_wfcq_dequeue_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
520}
521
ee990cac
MD
522template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking(
523 T head, struct cds_wfcq_tail *tail, int *state)
0cdbb569 524{
aaf0064b 525 return __cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
526 tail, state);
527}
528
ee990cac
MD
529template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking(
530 T head, struct cds_wfcq_tail *tail)
0cdbb569 531{
aaf0064b 532 return __cds_wfcq_dequeue_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
533}
534
ee990cac
MD
535template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking(
536 T head, struct cds_wfcq_tail *tail, int *state)
0cdbb569 537{
aaf0064b 538 return __cds_wfcq_dequeue_with_state_nonblocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
539 tail, state);
540}
541
ee990cac
MD
542template<typename T, typename U> static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking(
543 T dest_q_head,
0cdbb569 544 struct cds_wfcq_tail *dest_q_tail,
ee990cac 545 U src_q_head,
0cdbb569
MD
546 struct cds_wfcq_tail *src_q_tail)
547{
aaf0064b 548 return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 549 dest_q_tail,
aaf0064b 550 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
551 src_q_tail);
552}
553
ee990cac
MD
554template<typename T, typename U> static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
555 T dest_q_head,
0cdbb569 556 struct cds_wfcq_tail *dest_q_tail,
ee990cac 557 U *src_q_head,
0cdbb569
MD
558 struct cds_wfcq_tail *src_q_tail)
559{
aaf0064b 560 return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 561 dest_q_tail,
aaf0064b 562 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
563 src_q_tail);
564}
565
ee990cac
MD
566template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_first_blocking(
567 T head, struct cds_wfcq_tail *tail)
0cdbb569 568{
aaf0064b 569 return __cds_wfcq_first_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
570}
571
ee990cac
MD
572template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_first_nonblocking(
573 T head, struct cds_wfcq_tail *tail)
0cdbb569 574{
aaf0064b 575 return __cds_wfcq_first_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
576}
577
ee990cac
MD
578template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_next_blocking(
579 T head,
0cdbb569
MD
580 struct cds_wfcq_tail *tail,
581 struct cds_wfcq_node *node)
582{
aaf0064b 583 return __cds_wfcq_next_blocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
584}
585
ee990cac
MD
586template<typename T> static inline struct cds_wfcq_node *__cds_wfcq_next_nonblocking(
587 T head,
0cdbb569
MD
588 struct cds_wfcq_tail *tail,
589 struct cds_wfcq_node *node)
590{
aaf0064b 591 return __cds_wfcq_next_nonblocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
592}
593
8ad4ce58
MD
594#endif
595
596#endif /* _URCU_WFCQUEUE_H */
This page took 0.070721 seconds and 4 git commands to generate.