6cb4971c929c63f02d231ac1fbd6e15550784299
[urcu.git] / urcu / wfstack.h
1 #ifndef _URCU_WFSTACK_H
2 #define _URCU_WFSTACK_H
3
4 /*
5 * wfstack.h
6 *
7 * Userspace RCU library - Stack with Wait-Free push, Blocking pop.
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>
27 #include <assert.h>
28 #include <urcu/compiler.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 struct wfs_node {
35 struct wfs_node *next;
36 };
37
38 struct wfs_stack {
39 struct wfs_node *head;
40 pthread_mutex_t lock;
41 };
42
43 #ifdef _LGPL_SOURCE
44
45 #include <urcu/wfstack-static.h>
46
47 #define wfs_node_init _wfs_node_init
48 #define wfs_init _wfs_init
49 #define wfs_push _wfs_push
50 #define __wfs_pop_blocking ___wfs_pop_blocking
51 #define wfs_pop_blocking _wfs_pop_blocking
52
53 #else /* !_LGPL_SOURCE */
54
55 extern void wfs_node_init(struct wfs_node *node);
56 extern void wfs_init(struct wfs_stack *s);
57 extern void wfs_push(struct wfs_stack *s, struct wfs_node *node);
58 /* __wfs_pop_blocking: caller ensures mutual exclusion between pops */
59 extern struct wfs_node *__wfs_pop_blocking(struct wfs_stack *s);
60 extern struct wfs_node *wfs_pop_blocking(struct wfs_stack *s);
61
62 #endif /* !_LGPL_SOURCE */
63
64 #ifdef __cplusplus
65 }
66 #endif
67
68 #endif /* _URCU_WFSTACK_H */
This page took 0.029503 seconds and 3 git commands to generate.