8 auto* job =
reinterpret_cast<Job*
>(
head);
9 while (job !=
nullptr) {
10 auto* next =
static_cast<Job*
>(job->next);
19 auto head = _head.load(std::memory_order_acquire);
20 auto node =
reinterpret_cast<std::uintptr_t
>(&job);
21 while (
head != OneShotEvent::kAllDone) {
22 job.next =
reinterpret_cast<Job*
>(
head);
23 if (_head.compare_exchange_weak(
head,
node, std::memory_order_release, std::memory_order_acquire)) {
31 return _head.load(std::memory_order_acquire) == OneShotEvent::kAllDone;
51#ifdef YACLIB_LOG_DEBUG
52 auto head = _head.load(std::memory_order_relaxed);
55 _head.store(kEmpty, std::memory_order_relaxed);
Callable that can be executed in an IExecutor.
void Set() noexcept
Prevent pushing new jobs and Call()
void Call() noexcept
Get all jobs and Call them.
bool TryAdd(Job &job) noexcept
Add job to the MPSC event queue.
void Wait() noexcept
Wait Call or Set immediately return if Event is Ready.
bool Ready() noexcept
was or not Set
void Reset() noexcept
Reinitializes OneShotEvent, semantically the same as *this = {};
#define YACLIB_ASSERT(cond)
atomic< std::uintptr_t > atomic_uintptr_t
Contract< V, E > MakeContract()
Creates related future and promise.
Waiter is public for advanced users.