uatomic: Fix header guard comment
[urcu.git] / include / urcu / wfqueue.h
... / ...
CommitLineData
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
16extern "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
33struct cds_wfq_node {
34 struct cds_wfq_node *next;
35};
36
37struct 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
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
59static inline CDS_WFQ_DEPRECATED
60void cds_wfq_destroy(struct cds_wfq_queue *q)
61{
62 _cds_wfq_destroy(q);
63}
64
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}
82
83#else /* !_LGPL_SOURCE */
84
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
91extern CDS_WFQ_DEPRECATED
92void cds_wfq_destroy(struct cds_wfq_queue *q);
93
94extern CDS_WFQ_DEPRECATED
95void 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 */
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);
103
104#endif /* !_LGPL_SOURCE */
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif /* _URCU_WFQUEUE_H */
This page took 0.022632 seconds and 4 git commands to generate.