Phase 1 of deprecating liburcu-signal
[urcu.git] / include / urcu / wfqueue.h
CommitLineData
d3d3857f
MJ
1// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
4afee0a7
MD
5#ifndef _URCU_WFQUEUE_H
6#define _URCU_WFQUEUE_H
7
8/*
4afee0a7 9 * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue
4afee0a7
MD
10 */
11
12#include <pthread.h>
4afee0a7
MD
13#include <urcu/compiler.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
14748510
MD
19#ifndef CDS_WFQ_DEPRECATED
20#define CDS_WFQ_DEPRECATED \
706d1165 21 CDS_DEPRECATED("urcu/wfqueue.h is deprecated. Please use urcu/wfcqueue.h instead.")
14748510
MD
22#endif
23
4afee0a7
MD
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
16aa9ee8
DG
33struct cds_wfq_node {
34 struct cds_wfq_node *next;
4afee0a7
MD
35};
36
16aa9ee8
DG
37struct cds_wfq_queue {
38 struct cds_wfq_node *head, **tail;
39 struct cds_wfq_node dummy; /* Dummy node */
4afee0a7
MD
40 pthread_mutex_t lock;
41};
42
4d001e96 43#ifdef _LGPL_SOURCE
4afee0a7 44
af7c2dbe 45#include <urcu/static/wfqueue.h>
4afee0a7 46
14748510
MD
47static inline CDS_WFQ_DEPRECATED
48void cds_wfq_node_init(struct cds_wfq_node *node)
49{
50 _cds_wfq_node_init(node);
51}
52
53static inline CDS_WFQ_DEPRECATED
54void cds_wfq_init(struct cds_wfq_queue *q)
55{
56 _cds_wfq_init(q);
57}
58
200d100e
MD
59static inline CDS_WFQ_DEPRECATED
60void cds_wfq_destroy(struct cds_wfq_queue *q)
61{
62 _cds_wfq_destroy(q);
63}
64
14748510
MD
65static inline CDS_WFQ_DEPRECATED
66void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node)
67{
68 _cds_wfq_enqueue(q, node);
69}
70
71static inline CDS_WFQ_DEPRECATED
72struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
73{
74 return ___cds_wfq_dequeue_blocking(q);
75}
76
77static inline CDS_WFQ_DEPRECATED
78struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
79{
80 return _cds_wfq_dequeue_blocking(q);
81}
4afee0a7 82
4d001e96 83#else /* !_LGPL_SOURCE */
4afee0a7 84
14748510
MD
85extern CDS_WFQ_DEPRECATED
86void cds_wfq_node_init(struct cds_wfq_node *node);
87
88extern CDS_WFQ_DEPRECATED
89void cds_wfq_init(struct cds_wfq_queue *q);
90
200d100e
MD
91extern CDS_WFQ_DEPRECATED
92void cds_wfq_destroy(struct cds_wfq_queue *q);
93
14748510
MD
94extern CDS_WFQ_DEPRECATED
95void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node);
96
16aa9ee8 97/* __cds_wfq_dequeue_blocking: caller ensures mutual exclusion between dequeues */
14748510
MD
98extern CDS_WFQ_DEPRECATED
99struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
100
101extern CDS_WFQ_DEPRECATED
102struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
4afee0a7 103
4d001e96 104#endif /* !_LGPL_SOURCE */
4afee0a7
MD
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif /* _URCU_WFQUEUE_H */
This page took 0.049884 seconds and 4 git commands to generate.