BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Data Structures | Public Member Functions | Protected Member Functions
BeeeOn::WaitCondition Class Reference

WaitCondition works as a barrier that waits until some condition is met. When the condition is met and broadcasted, all waiting threads are woken up. More...

#include <WaitCondition.h>

Data Structures

class  Broadcaster
 Broadcaster can be used to ensure that the broadcast is called even in cast when an unexpected exception is thrown. Broadcaster calls broadcast() from its destructor unless it has been called explicitly. More...
 

Public Member Functions

 WaitCondition (bool repeat=true)
 
void wait (const Poco::Timespan &timeout=-1)
 Wait until the condition is broadcasted. Negative timeout would block infinitly (until broadcasted). More...
 
bool tryWait (const Poco::Timespan &timeout=-1)
 Wait until the condition is broadcasted. Negative timeout would block infinitly (until broadcasted). More...
 
void broadcast ()
 Broadcast that the condition has been met.
 

Protected Member Functions

long toMilliseconds (const Poco::Timespan &timeout) const
 Convert the given timeout into milliseconds. Negative value is converted to -1. Timeout shorter then 1 ms is converted to 1 ms.
 
bool doWait (long ms)
 The actual waiting logic.
 

Detailed Description

WaitCondition works as a barrier that waits until some condition is met. When the condition is met and broadcasted, all waiting threads are woken up.

The WaitCondition can be configured to be non-repetitive. I.e. after the first broadcast, all calls to wait or tryWait would immediatelly return as successful.

Member Function Documentation

bool WaitCondition::tryWait ( const Poco::Timespan &  timeout = -1)

Wait until the condition is broadcasted. Negative timeout would block infinitly (until broadcasted).

Returns
true if woken by broadcast, false when timeout has exceeded
void WaitCondition::wait ( const Poco::Timespan &  timeout = -1)

Wait until the condition is broadcasted. Negative timeout would block infinitly (until broadcasted).

Exceptions
Poco::TimeoutExceptionwhen timeout is exceeded

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