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::fiber {
8
9class AtomicFlag : public AtomicWait<bool> {
10 using Base = AtomicWait<bool>;
11
12 public:
13 using Base::Base;
14
15 void clear(std::memory_order) volatile noexcept {
16 _value = false;
17 }
18 void clear(std::memory_order) noexcept {
19 _value = false;
20 }
21
22 bool test_and_set(std::memory_order) volatile noexcept {
23 auto val = _value;
24 _value = true;
25 return val;
26 }
27 bool test_and_set(std::memory_order) noexcept {
28 auto val = _value;
29 _value = true;
30 return val;
31 }
32
33#if YACLIB_FUTEX != 0
34 bool test(std::memory_order) const volatile noexcept {
35 return _value;
36 }
37 bool test(std::memory_order) const noexcept {
38 return _value;
39 }
40#endif
41 private:
42 using Base::_value;
43};
44
45} // namespace yaclib::detail::fiber
bool test_and_set(std::memory_order) noexcept
bool test_and_set(std::memory_order) volatile noexcept
void clear(std::memory_order) volatile noexcept
void clear(std::memory_order) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25