Build system: use SPDX identifiers
[userspace-rcu.git] / include / urcu / wfqueue.h
CommitLineData
4afee0a7
MD
1#ifndef _URCU_WFQUEUE_H
2#define _URCU_WFQUEUE_H
3
4/*
5 * wfqueue.h
6 *
7 * Userspace RCU library - Queue with Wait-Free Enqueue/Blocking Dequeue
8 *
9 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#include <pthread.h>
4afee0a7
MD
27#include <urcu/compiler.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
14748510
MD
33#ifndef CDS_WFQ_DEPRECATED
34#define CDS_WFQ_DEPRECATED \
706d1165 35 CDS_DEPRECATED("urcu/wfqueue.h is deprecated. Please use urcu/wfcqueue.h instead.")
14748510
MD
36#endif
37
4afee0a7
MD
38/*
39 * Queue with wait-free enqueue/blocking dequeue.
40 * This implementation adds a dummy head node when the queue is empty to ensure
41 * we can always update the queue locklessly.
42 *
43 * Inspired from half-wait-free/half-blocking queue implementation done by
44 * Paul E. McKenney.
45 */
46
16aa9ee8
DG
47struct cds_wfq_node {
48 struct cds_wfq_node *next;
4afee0a7
MD
49};
50
16aa9ee8
DG
51struct cds_wfq_queue {
52 struct cds_wfq_node *head, **tail;
53 struct cds_wfq_node dummy; /* Dummy node */
4afee0a7
MD
54 pthread_mutex_t lock;
55};
56
4d001e96 57#ifdef _LGPL_SOURCE
4afee0a7 58
af7c2dbe 59#include <urcu/static/wfqueue.h>
4afee0a7 60
14748510
MD
61static inline CDS_WFQ_DEPRECATED
62void cds_wfq_node_init(struct cds_wfq_node *node)
63{
64 _cds_wfq_node_init(node);
65}
66
67static inline CDS_WFQ_DEPRECATED
68void cds_wfq_init(struct cds_wfq_queue *q)
69{
70 _cds_wfq_init(q);
71}
72
200d100e
MD
73static inline CDS_WFQ_DEPRECATED
74void cds_wfq_destroy(struct cds_wfq_queue *q)
75{
76 _cds_wfq_destroy(q);
77}
78
14748510
MD
79static inline CDS_WFQ_DEPRECATED
80void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node)
81{
82 _cds_wfq_enqueue(q, node);
83}
84
85static inline CDS_WFQ_DEPRECATED
86struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
87{
88 return ___cds_wfq_dequeue_blocking(q);
89}
90
91static inline CDS_WFQ_DEPRECATED
92struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
93{
94 return _cds_wfq_dequeue_blocking(q);
95}
4afee0a7 96
4d001e96 97#else /* !_LGPL_SOURCE */
4afee0a7 98
14748510
MD
99extern CDS_WFQ_DEPRECATED
100void cds_wfq_node_init(struct cds_wfq_node *node);
101
102extern CDS_WFQ_DEPRECATED
103void cds_wfq_init(struct cds_wfq_queue *q);
104
200d100e
MD
105extern CDS_WFQ_DEPRECATED
106void cds_wfq_destroy(struct cds_wfq_queue *q);
107
14748510
MD
108extern CDS_WFQ_DEPRECATED
109void cds_wfq_enqueue(struct cds_wfq_queue *q, struct cds_wfq_node *node);
110
16aa9ee8 111/* __cds_wfq_dequeue_blocking: caller ensures mutual exclusion between dequeues */
14748510
MD
112extern CDS_WFQ_DEPRECATED
113struct cds_wfq_node *__cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
114
115extern CDS_WFQ_DEPRECATED
116struct cds_wfq_node *cds_wfq_dequeue_blocking(struct cds_wfq_queue *q);
4afee0a7 117
4d001e96 118#endif /* !_LGPL_SOURCE */
4afee0a7
MD
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* _URCU_WFQUEUE_H */
This page took 0.049736 seconds and 4 git commands to generate.