Class EventCount

Class Documentation

class EventCount

the sleep of threads until a condition holds, woken by notify()

Public Types

using Key = std::uint32_t

the epoch a waiter saw

Public Functions

EventCount(void) = default
EventCount(const EventCount&) = delete
EventCount &operator=(const EventCount&) = delete
inline Key prepareWait(void) noexcept

announces a waiter and returns the epoch, before the last look at the condition

inline void cancelWait(Key k) noexcept

withdraws the waiter, the condition being true, unless a notifier already withdrew it (the epoch is no longer k)

inline void commitWait(Key k) noexcept

sleeps while the epoch is k; the notifier that advanced it withdrew the waiter

inline void notify(void) noexcept

wakes the waiters, after the condition was made true: it advances the epoch and withdraws them all at once, so that the notifications that follow, before they run, find nobody to wake; when nobody waits, a light fence and a read

template<class P>
inline void await(P &&p, std::int64_t spin = 20000)

returns when p() is true: it looks again and again for up to spin nanoseconds, with a pause of the processor between the looks, and then sleeps between them

inline std::uint32_t waiters(void) const noexcept

the number of the threads announced as waiters at some moment