Add support for custom memory allocators for rculfhash
[urcu.git] / include / urcu / rculfqueue.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
c3f74cb2
MD
5#ifndef _URCU_RCULFQUEUE_H
6#define _URCU_RCULFQUEUE_H
7
453629a9 8/*
453629a9 9 * Userspace RCU library - Lock-Free RCU Queue
453629a9
MD
10 */
11
453629a9 12
0e2e9380
MD
13#ifdef __cplusplus
14extern "C" {
15#endif
16
d9b52143 17struct cds_lfq_queue_rcu;
d95d5cb9 18struct rcu_head;
d9b52143 19
16aa9ee8
DG
20struct cds_lfq_node_rcu {
21 struct cds_lfq_node_rcu *next;
fbdb32f6 22 int dummy;
453629a9
MD
23};
24
16aa9ee8 25struct cds_lfq_queue_rcu {
fbdb32f6 26 struct cds_lfq_node_rcu *head, *tail;
6e5f88cf
MD
27 void (*queue_call_rcu)(struct rcu_head *head,
28 void (*func)(struct rcu_head *head));
453629a9
MD
29};
30
3d02c34d 31#ifdef _LGPL_SOURCE
453629a9 32
af7c2dbe 33#include <urcu/static/rculfqueue.h>
453629a9 34
4157e1ac
MD
35#define cds_lfq_node_init_rcu _cds_lfq_node_init_rcu
36#define cds_lfq_init_rcu _cds_lfq_init_rcu
37#define cds_lfq_destroy_rcu _cds_lfq_destroy_rcu
38#define cds_lfq_enqueue_rcu _cds_lfq_enqueue_rcu
39#define cds_lfq_dequeue_rcu _cds_lfq_dequeue_rcu
453629a9 40
3d02c34d 41#else /* !_LGPL_SOURCE */
453629a9 42
16aa9ee8 43extern void cds_lfq_node_init_rcu(struct cds_lfq_node_rcu *node);
6e5f88cf
MD
44extern void cds_lfq_init_rcu(struct cds_lfq_queue_rcu *q,
45 void queue_call_rcu(struct rcu_head *head,
46 void (*func)(struct rcu_head *head)));
e17d9985
MD
47/*
48 * The queue should be emptied before calling destroy.
49 *
50 * Return 0 on success, -EPERM if queue is not empty.
51 */
52extern int cds_lfq_destroy_rcu(struct cds_lfq_queue_rcu *q);
d9b52143
MD
53
54/*
6e5f88cf 55 * Should be called under rcu read lock critical section.
d9b52143
MD
56 */
57extern void cds_lfq_enqueue_rcu(struct cds_lfq_queue_rcu *q,
58 struct cds_lfq_node_rcu *node);
453629a9
MD
59
60/*
6e5f88cf 61 * Should be called under rcu read lock critical section.
d9b52143 62 *
e17d9985
MD
63 * The caller must wait for a grace period to pass before freeing the returned
64 * node or modifying the cds_lfq_node_rcu structure.
65 * Returns NULL if queue is empty.
453629a9 66 */
a34df756
MD
67extern
68struct cds_lfq_node_rcu *cds_lfq_dequeue_rcu(struct cds_lfq_queue_rcu *q);
453629a9 69
3d02c34d 70#endif /* !_LGPL_SOURCE */
c3f74cb2 71
0e2e9380
MD
72#ifdef __cplusplus
73}
74#endif
75
c3f74cb2 76#endif /* _URCU_RCULFQUEUE_H */
This page took 0.050107 seconds and 4 git commands to generate.