| 1 | /* |
| 2 | * Copyright (C) 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 3 | * 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU Lesser General Public License, version 2.1 only, |
| 7 | * as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
| 12 | * for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public License |
| 15 | * along with this program; if not, write to the Free Software Foundation, |
| 16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | * |
| 18 | * This code is originally adapted from userspace-rcu's urcu-wait.h |
| 19 | */ |
| 20 | |
| 21 | #ifndef LTTNG_WAITER_H |
| 22 | #define LTTNG_WAITER_H |
| 23 | |
| 24 | #define _LGPL_SOURCE |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | #include <urcu/wfstack.h> |
| 28 | #include <stdbool.h> |
| 29 | #include "macros.h" |
| 30 | |
| 31 | struct lttng_waiter { |
| 32 | struct cds_wfs_node wait_queue_node; |
| 33 | int32_t state; |
| 34 | }; |
| 35 | |
| 36 | LTTNG_HIDDEN |
| 37 | void lttng_waiter_init(struct lttng_waiter *waiter); |
| 38 | |
| 39 | LTTNG_HIDDEN |
| 40 | void lttng_waiter_wait(struct lttng_waiter *waiter); |
| 41 | |
| 42 | /* |
| 43 | * lttng_waiter_wake_up must only be called by a single waker. |
| 44 | * It is invalid for multiple "wake" operations to be invoked |
| 45 | * on a single waiter without re-initializing it before. |
| 46 | */ |
| 47 | LTTNG_HIDDEN |
| 48 | void lttng_waiter_wake_up(struct lttng_waiter *waiter); |
| 49 | |
| 50 | #endif /* LTTNG_WAITER_H */ |