2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
20 * Wrapper around an urcu read lock which satisfies the 'Mutex' named
21 * requirements of C++11. Satisfying those requirements facilitates the use of
22 * standard concurrency support library facilities.
24 * read_lock is under the details namespace since it is unlikely to be used
25 * directly by exception-safe code. See read_lock_guard.
29 read_lock() = default;
30 ~read_lock() = default;
32 /* "Not copyable" and "not moveable" Mutex requirements. */
33 read_lock(read_lock const&) = delete;
34 read_lock(read_lock&&) = delete;
35 read_lock& operator=(read_lock&&) = delete;
36 read_lock& operator=(const read_lock&) = delete;
54 } /* namespace details */
57 * Provides the basic concept of std::lock_guard for rcu reader locks.
59 * The RCU reader lock is held for the duration of lock_guard's lifetime.
61 class read_lock_guard {
63 read_lock_guard() = default;
64 ~read_lock_guard() = default;
66 read_lock_guard(const read_lock_guard&) = delete;
67 read_lock_guard(read_lock_guard&&) = delete;
68 read_lock_guard& operator=(read_lock_guard&&) = delete;
69 read_lock_guard& operator=(const read_lock_guard&) = delete;
72 details::read_lock _lock;
73 std::lock_guard<details::read_lock> _guard{ _lock };
76 using unique_read_lock = std::unique_lock<details::read_lock>;
78 } /* namespace urcu */
79 } /* namespace lttng */
81 #endif /* LTTNG_URCU_H */