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