YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
atomic_event.cpp
Go to the documentation of this file.
1
#include <
yaclib/util/detail/atomic_event.hpp
>
2
3
namespace
yaclib::detail
{
4
5
AtomicEvent::Token
AtomicEvent::Make
()
noexcept
{
6
return
{};
7
}
8
9
void
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
19
void
AtomicEvent::Set
()
noexcept
{
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
30
void
AtomicEvent::Reset
()
noexcept
{
31
_state.store(0, std::memory_order_relaxed);
32
}
33
34
}
// namespace yaclib::detail
atomic_event.hpp
yaclib::detail::AtomicEvent::Set
void Set() noexcept
Definition
atomic_event.cpp:19
yaclib::detail::AtomicEvent::Make
static Token Make() noexcept
Definition
atomic_event.cpp:5
yaclib::detail::AtomicEvent::Reset
void Reset() noexcept
Definition
atomic_event.cpp:30
yaclib::detail::AtomicEvent::Token
Unit Token
Definition
atomic_event.hpp:12
yaclib::detail::AtomicEvent::Wait
void Wait(Token) noexcept
Definition
atomic_event.cpp:9
yaclib::detail
Definition
base_core.hpp:18
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
src
util
atomic_event.cpp
Generated by
1.9.8