rcu lfqueue: make dequeue lockless by helping out other dequeuers
[urcu.git] / urcu / rculfqueue.h
CommitLineData
c3f74cb2
MD
1#ifndef _URCU_RCULFQUEUE_H
2#define _URCU_RCULFQUEUE_H
3
453629a9
MD
4/*
5 * rculfqueue.h
6 *
7 * Userspace RCU library - Lock-Free RCU Queue
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
453629a9 26#include <assert.h>
e17d9985 27#include <urcu-call-rcu.h>
453629a9 28
0e2e9380
MD
29#ifdef __cplusplus
30extern "C" {
31#endif
32
d9b52143
MD
33struct cds_lfq_queue_rcu;
34
16aa9ee8
DG
35struct cds_lfq_node_rcu {
36 struct cds_lfq_node_rcu *next;
453629a9
MD
37};
38
16aa9ee8 39struct cds_lfq_queue_rcu {
909292c2 40 struct cds_lfq_node_rcu *head, *tail, *dummy;
e17d9985
MD
41 void (*queue_call_rcu)(struct rcu_head *head,
42 void (*func)(struct rcu_head *head));
453629a9
MD
43};
44
3d02c34d 45#ifdef _LGPL_SOURCE
453629a9 46
af7c2dbe 47#include <urcu/static/rculfqueue.h>
453629a9 48
a34df756 49#define cds_lfq_node_init_rcu _cds_lfq_node_init_rcu
16aa9ee8 50#define cds_lfq_init_rcu _cds_lfq_init_rcu
e17d9985 51#define cds_lfq_destroy_rcu _cds_lfq_destroy_rcu
16aa9ee8
DG
52#define cds_lfq_enqueue_rcu _cds_lfq_enqueue_rcu
53#define cds_lfq_dequeue_rcu _cds_lfq_dequeue_rcu
453629a9 54
3d02c34d 55#else /* !_LGPL_SOURCE */
453629a9 56
16aa9ee8 57extern void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node);
d9b52143 58extern void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q,
e17d9985
MD
59 void queue_call_rcu(struct rcu_head *head,
60 void (*func)(struct rcu_head *head)));
61/*
62 * The queue should be emptied before calling destroy.
63 *
64 * Return 0 on success, -EPERM if queue is not empty.
65 */
66extern int cds_lfq_destroy_rcu(struct cds_lfq_queue_rcu *q);
d9b52143
MD
67
68/*
69 * Should be called under rcu read lock critical section.
70 */
71extern void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q,
72 struct cds_lfq_node_rcu *node);
453629a9
MD
73
74/*
d9b52143
MD
75 * Should be called under rcu read lock critical section.
76 *
e17d9985
MD
77 * The caller must wait for a grace period to pass before freeing the returned
78 * node or modifying the cds_lfq_node_rcu structure.
79 * Returns NULL if queue is empty.
453629a9 80 */
a34df756
MD
81extern
82struct cds_lfq_node_rcu *cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q);
453629a9 83
3d02c34d 84#endif /* !_LGPL_SOURCE */
c3f74cb2 85
0e2e9380
MD
86#ifdef __cplusplus
87}
88#endif
89
c3f74cb2 90#endif /* _URCU_RCULFQUEUE_H */
This page took 0.026279 seconds and 4 git commands to generate.