YACLib
C++ library for concurrent tasks execution
|
This class useful to wait or co_await some event. More...
#include <one_shot_event.hpp>
Classes | |
struct | TimedWaiter |
Public only because Waiter is public. More... | |
struct | Waiter |
Waiter is public for advanced users. More... | |
Public Member Functions | |
bool | TryAdd (Job &job) noexcept |
Add job to the MPSC event queue. | |
bool | Ready () noexcept |
was or not Set | |
void | Wait () noexcept |
Wait Call or Set immediately return if Event is Ready. | |
template<typename Rep , typename Period > | |
YACLIB_INLINE bool | WaitFor (const std::chrono::duration< Rep, Period > &timeout_duration) |
WaitFor Call or Set immediately return if Event is Ready. | |
template<typename Clock , typename Duration > | |
YACLIB_INLINE bool | WaitUntil (const std::chrono::time_point< Clock, Duration > &timeout_time) |
WaitUntil Call or Set immediately return if Event is Ready. | |
void | Call () noexcept |
Get all jobs and Call them. | |
void | Set () noexcept |
Prevent pushing new jobs and Call() | |
void | Reset () noexcept |
Reinitializes OneShotEvent, semantically the same as *this = {}; | |
This class useful to wait or co_await some event.
In general it's MPSC pattern: Multi threads can call TryAdd/Wait/Await* Single thread can call Call or Set
Definition at line 27 of file one_shot_event.hpp.
|
noexcept |
Get all jobs and Call them.
Definition at line 42 of file one_shot_event.cpp.
References yaclib::MakeContract().
|
noexcept |
was or not Set
Definition at line 30 of file one_shot_event.cpp.
|
noexcept |
Reinitializes OneShotEvent, semantically the same as *this = {};
If you don't explicitly call this method, then after the first one, Wait will always return immediately.
Definition at line 50 of file one_shot_event.cpp.
References yaclib::MakeContract(), and YACLIB_ASSERT.
|
noexcept |
Prevent pushing new jobs and Call()
Definition at line 46 of file one_shot_event.cpp.
References yaclib::MakeContract().
Referenced by yaclib::OneShotEvent::Waiter::Call().
Add job to the MPSC event queue.
When Call or Set will be called also will be called job->Call
But only if TryAdd return true. It can return false if on Event already was called Set
Definition at line 18 of file one_shot_event.cpp.
References yaclib::MakeContract().
Referenced by Wait().
|
noexcept |
Wait Call or Set immediately return if Event is Ready.
Definition at line 34 of file one_shot_event.cpp.
References yaclib::detail::MutexEvent::Make(), yaclib::MakeContract(), and TryAdd().
|
inline |
WaitFor Call or Set immediately return if Event is Ready.
Definition at line 54 of file one_shot_event.hpp.
References yaclib::MakeContract().
|
inline |
WaitUntil Call or Set immediately return if Event is Ready.
Definition at line 63 of file one_shot_event.hpp.
References yaclib::MakeContract().