Class Event

Class Documentation

class Event

A thread-safe event object, mimicking python’s threading.Event.

Public Functions

bool is_set() const

Check whether internal status has been set.

Returns:

True if the event has been set.

void set()

Set the internal status, notifies all waiting threads.

void clear()

Clear the internal status so the event can be reused.

bool check_and_clear()

Check whether internal status has been set, and clear the status.

Returns:

True if event has been set.

bool wait_for(const std::chrono::milliseconds &timeout)

Wait for the event to be set, with a timeout. Handles spurious wakeups.

Template Parameters:
  • Rep – (from std::chrono) Numerical type that represents number of ticks.

  • Period – (from std::chrono) std::ratio representing seconds per tick.

Parameters:

timeout

Returns:

True if the event was already set, or became set within the timeout.

Returns:

False if the event was not set within the timeout

template<class Rep, class Period>
inline bool wait_for(const std::chrono::duration<Rep, Period> &timeout)