Fix: consumerd: slow metadata push slows down application registration
[lttng-tools.git] / src / common / waiter.hpp
1 /*
2 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 *
7 * This code is originally adapted from userspace-rcu's urcu-wait.h
8 */
9
10 #ifndef LTTNG_WAITER_H
11 #define LTTNG_WAITER_H
12
13 #define _LGPL_SOURCE
14
15 #include "macros.hpp"
16
17 #include <stdbool.h>
18 #include <stdint.h>
19 #include <urcu/wfstack.h>
20
21 struct lttng_waiter {
22 struct cds_wfs_node wait_queue_node;
23 int32_t state;
24 };
25
26 struct lttng_wait_queue {
27 struct cds_wfs_stack stack;
28 };
29
30 void lttng_waiter_init(struct lttng_waiter *waiter);
31
32 void lttng_waiter_wait(struct lttng_waiter *waiter);
33
34 /*
35 * lttng_waiter_wake must only be called by a single waker.
36 * It is invalid for multiple "wake" operations to be invoked
37 * on a single waiter without re-initializing it before.
38 */
39 void lttng_waiter_wake(struct lttng_waiter *waiter);
40
41 void lttng_wait_queue_init(struct lttng_wait_queue *queue);
42
43 /*
44 * Atomically add a waiter to a wait queue.
45 * A full memory barrier is issued before being added to the wait queue.
46 */
47 void lttng_wait_queue_add(struct lttng_wait_queue *queue, struct lttng_waiter *waiter);
48
49 /*
50 * Wake every waiter present in the wait queue and remove them from
51 * the queue.
52 */
53 void lttng_wait_queue_wake_all(struct lttng_wait_queue *queue);
54
55 #endif /* LTTNG_WAITER_H */
This page took 0.031577 seconds and 5 git commands to generate.