YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
atomic_flag.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/config.hpp>
6
7namespace yaclib::detail {
8
9template <typename Impl>
10class AtomicFlag : public AtomicWait<Impl, bool> {
12
13 public:
14 using Base::Base;
15
16 void clear(std::memory_order order = std::memory_order_seq_cst) volatile noexcept {
17 YACLIB_INJECT_FAULT(Impl::clear(order));
18 }
19 void clear(std::memory_order order = std::memory_order_seq_cst) noexcept {
20 YACLIB_INJECT_FAULT(Impl::clear(order));
21 }
22
23 bool test_and_set(std::memory_order order = std::memory_order_seq_cst) volatile noexcept {
24 YACLIB_INJECT_FAULT(auto r = Impl::test_and_set(order));
25 return r;
26 }
27 bool test_and_set(std::memory_order order = std::memory_order_seq_cst) noexcept {
28 YACLIB_INJECT_FAULT(auto r = Impl::test_and_set(order));
29 return r;
30 }
31
32#if YACLIB_FUTEX != 0
33 bool test(std::memory_order order = std::memory_order::seq_cst) const volatile noexcept {
34 YACLIB_INJECT_FAULT(auto r = Impl::test(order));
35 return r;
36 }
37 bool test(std::memory_order order = std::memory_order::seq_cst) const noexcept {
38 YACLIB_INJECT_FAULT(auto r = Impl::test(order));
39 return r;
40 }
41#endif
42};
43
44} // namespace yaclib::detail
void clear(std::memory_order order=std::memory_order_seq_cst) volatile noexcept
bool test_and_set(std::memory_order order=std::memory_order_seq_cst) noexcept
bool test_and_set(std::memory_order order=std::memory_order_seq_cst) volatile noexcept
void clear(std::memory_order order=std::memory_order_seq_cst) noexcept
#define YACLIB_INJECT_FAULT(statement)
Definition inject.hpp:20
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25