ark::core::EventCondition

Defined in header “ark/core/event_condition.hh”.


Provides a simple condition mechanism that allows you to sleep on (and wake up from) listening to a file descriptor. This can be faster that using a mutex and condition variable pair, and can also be nice if you are waiting on other descriptors (such as sockets) and want to also wait on an event.

Methods

  • EventCondition()
    Constructor. Initializes a new condition.

  • ~EventCondition()
    Destructor. Frees the condition.

  • EventCondition()
    Disable copies. Otherwise we’re not sure who owns the descriptor for cleanup.

  • EventCondition & operator=()

  • native_handle_type native_handle()
    Returns the underlying native handle for this object.

  • void notify()
    Notifies this condition. Anything sleeping on it will wake up.

  • bool clear()
    Clears the notification state. Waiting on this will block again until notify() is called. Returns true if the condition was set, false otherwise.

    NOLINTNEXTLINE(modernize-use-nodiscard)

  • bool wait_for(std::chrono::nanoseconds duration)
    Waits for the condition to become notified.