YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
atomic_event.cpp
Go to the documentation of this file.
2
3namespace yaclib::detail {
4
8
9void AtomicEvent::Wait(Token) noexcept {
10#if YACLIB_FUTEX == 1
11 _state.wait(0, std::memory_order_relaxed);
12 while (_state.load(std::memory_order_acquire) != 2) {
13 }
14#elif YACLIB_FUTEX == 2
15 _state.wait(0, std::memory_order_acquire);
16#endif
17}
18
20#if YACLIB_FUTEX == 1
21 _state.store(1, std::memory_order_relaxed);
22 _state.notify_one();
23 _state.store(2, std::memory_order_release);
24#elif YACLIB_FUTEX == 2
25 _state.store(1, std::memory_order_release);
26 _state.notify_one();
27#endif
28}
29
31 _state.store(0, std::memory_order_relaxed);
32}
33
34} // namespace yaclib::detail
static Token Make() noexcept
void Wait(Token) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25