CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | List of all members
CppCommon::EventManualReset Class Reference

Manual-reset event synchronization primitive. More...

#include <event_manual_reset.h>

Public Member Functions

 EventManualReset (bool signaled=false)
 Default class constructor. More...
 
 EventManualReset (const EventManualReset &)=delete
 
 EventManualReset (EventManualReset &&event)=delete
 
 ~EventManualReset ()
 
EventManualResetoperator= (const EventManualReset &)=delete
 
EventManualResetoperator= (EventManualReset &&event)=delete
 
void Reset ()
 Reset the event. More...
 
void Signal ()
 Signal one of waiting thread about event occurred. More...
 
bool TryWait ()
 Try to wait the event without block. More...
 
bool TryWaitFor (const Timespan &timespan)
 Try to wait the event for the given timespan. More...
 
bool TryWaitUntil (const UtcTimestamp &timestamp)
 Try to wait the event until the given timestamp. More...
 
void Wait ()
 Try to wait the event with block. More...
 

Detailed Description

Manual-reset event synchronization primitive.

Manual-reset event synchronization primitive allows multiple threads to wait for some event occurred and signal all waiting threads at the time. If the event is in the signaled state no thread will wait for it until the event is reset.

Thread-safe.

https://en.wikipedia.org/wiki/Event_(synchronization_primitive)

Examples
threads_event_manual_reset.cpp.

Definition at line 28 of file event_manual_reset.h.

Constructor & Destructor Documentation

◆ EventManualReset() [1/3]

CppCommon::EventManualReset::EventManualReset ( bool  signaled = false)
explicit

Default class constructor.

Parameters
signaled- Signaled event initial state (default is false)

Definition at line 183 of file event_manual_reset.cpp.

◆ EventManualReset() [2/3]

CppCommon::EventManualReset::EventManualReset ( const EventManualReset )
delete

◆ EventManualReset() [3/3]

CppCommon::EventManualReset::EventManualReset ( EventManualReset &&  event)
delete

◆ ~EventManualReset()

CppCommon::EventManualReset::~EventManualReset ( )

Definition at line 194 of file event_manual_reset.cpp.

Member Function Documentation

◆ operator=() [1/2]

EventManualReset& CppCommon::EventManualReset::operator= ( const EventManualReset )
delete

◆ operator=() [2/2]

EventManualReset& CppCommon::EventManualReset::operator= ( EventManualReset &&  event)
delete

◆ Reset()

void CppCommon::EventManualReset::Reset ( )

Reset the event.

If the event is in the signaled state then it will be reset to non signaled state. As the result other threads that wait for the event will be blocked.

Will not block.

Definition at line 200 of file event_manual_reset.cpp.

◆ Signal()

void CppCommon::EventManualReset::Signal ( )

Signal one of waiting thread about event occurred.

If some threads are waiting for the event all of them will be signaled and continued.

Will not block.

Definition at line 201 of file event_manual_reset.cpp.

◆ TryWait()

bool CppCommon::EventManualReset::TryWait ( )

Try to wait the event without block.

Will not block.

Returns
'true' if the event was occurred before and no other threads were signaled, 'false' if the event was not occurred before

Definition at line 203 of file event_manual_reset.cpp.

◆ TryWaitFor()

bool CppCommon::EventManualReset::TryWaitFor ( const Timespan timespan)

Try to wait the event for the given timespan.

Will block for the given timespan in the worst case.

Parameters
timespan- Timespan to wait for the event
Returns
'true' if the event was occurred, 'false' if the event was not occurred

Definition at line 204 of file event_manual_reset.cpp.

◆ TryWaitUntil()

bool CppCommon::EventManualReset::TryWaitUntil ( const UtcTimestamp timestamp)
inline

Try to wait the event until the given timestamp.

Will block until the given timestamp in the worst case.

Parameters
timestamp- Timestamp to stop wait for the event
Returns
'true' if the event was occurred, 'false' if the event was not occurred

Definition at line 83 of file event_manual_reset.h.

◆ Wait()

void CppCommon::EventManualReset::Wait ( )

Try to wait the event with block.

Will block.

Definition at line 206 of file event_manual_reset.cpp.


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