ngscopeclient 0.1-dev+51fbda87c
Public Member Functions | Protected Attributes | List of all members
Event Class Reference

Synchronization primitive for sending a "something is ready" notification to a thread. More...

#include <Event.h>

Public Member Functions

void Signal ()
 Sends an event to the receiving thread.
 
bool SignalIfNotAlreadySignaled ()
 Sends an event to the receiving thread. More...
 
void SignalExactlyOnce (Event &processedEvent)
 Sends an event to the receiving thread. More...
 
void Block ()
 Blocks until the event is signaled.
 
bool Peek (bool clearReady=true)
 Checks if the event is signaled, and returns immediately without blocking regardless of event state. More...
 
void Clear ()
 Clears the event state if it's currently signaled.
 

Protected Attributes

std::mutex m_mutex
 
std::condition_variable m_cond
 
std::atomic_bool m_ready
 

Detailed Description

Synchronization primitive for sending a "something is ready" notification to a thread.

Unlike std::condition_variable, an Event can be signaled before the receiver has started to wait.

Member Function Documentation

◆ Peek()

bool Event::Peek ( bool  clearReady = true)
inline

Checks if the event is signaled, and returns immediately without blocking regardless of event state.

This clears the event-pending flag if clearReady is set.

◆ SignalExactlyOnce()

void Event::SignalExactlyOnce ( Event processedEvent)
inline

Sends an event to the receiving thread.

If another event is pending, blocks until that one has been processed to avoid dropping events.

Parameters
processedEventEvent indicating that the previous message has been processed completely

◆ SignalIfNotAlreadySignaled()

bool Event::SignalIfNotAlreadySignaled ( )
inline

Sends an event to the receiving thread.

If another event is pending, returns false indicating no submission was actually made


The documentation for this class was generated from the following file: