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

Named auto-reset event synchronization primitive. More...

#include <named_event_auto_reset.h>

Public Member Functions

 NamedEventAutoReset (const std::string &name, bool signaled=false)
 Default class constructor. More...
 
 NamedEventAutoReset (const NamedEventAutoReset &)=delete
 
 NamedEventAutoReset (NamedEventAutoReset &&event)=delete
 
 ~NamedEventAutoReset ()
 
NamedEventAutoResetoperator= (const NamedEventAutoReset &)=delete
 
NamedEventAutoResetoperator= (NamedEventAutoReset &&event)=delete
 
const std::string & name () const
 Get the event name. 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

Named auto-reset event synchronization primitive.

Named auto-reset event behaves as a simple auto-reset event but could be shared between processes on the same machine.

Thread-safe.

See also
EventAutoReset
Examples
threads_named_event_auto_reset.cpp.

Definition at line 28 of file named_event_auto_reset.h.

Constructor & Destructor Documentation

◆ NamedEventAutoReset() [1/3]

CppCommon::NamedEventAutoReset::NamedEventAutoReset ( const std::string &  name,
bool  signaled = false 
)
explicit

Default class constructor.

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

Definition at line 229 of file named_event_auto_reset.cpp.

◆ NamedEventAutoReset() [2/3]

CppCommon::NamedEventAutoReset::NamedEventAutoReset ( const NamedEventAutoReset )
delete

◆ NamedEventAutoReset() [3/3]

CppCommon::NamedEventAutoReset::NamedEventAutoReset ( NamedEventAutoReset &&  event)
delete

◆ ~NamedEventAutoReset()

CppCommon::NamedEventAutoReset::~NamedEventAutoReset ( )

Definition at line 240 of file named_event_auto_reset.cpp.

Member Function Documentation

◆ name()

const std::string & CppCommon::NamedEventAutoReset::name ( ) const

Get the event name.

Definition at line 246 of file named_event_auto_reset.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ Signal()

void CppCommon::NamedEventAutoReset::Signal ( )

Signal one of waiting thread about event occurred.

If some threads are waiting for the event one will be chosen, signaled and continued. The order of thread signalization by auto-reset event is not guaranteed.

Will not block.

Examples
threads_named_event_auto_reset.cpp.

Definition at line 248 of file named_event_auto_reset.cpp.

◆ TryWait()

bool CppCommon::NamedEventAutoReset::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 250 of file named_event_auto_reset.cpp.

◆ TryWaitFor()

bool CppCommon::NamedEventAutoReset::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 251 of file named_event_auto_reset.cpp.

◆ TryWaitUntil()

bool CppCommon::NamedEventAutoReset::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 79 of file named_event_auto_reset.h.

◆ Wait()

void CppCommon::NamedEventAutoReset::Wait ( )

Try to wait the event with block.

Will block.

Examples
threads_named_event_auto_reset.cpp.

Definition at line 253 of file named_event_auto_reset.cpp.


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