Tkrzw
Public Member Functions | List of all members
tkrzw::SignalBroker::Waiter Class Reference

Handler to wait for the signal. More...

#include <tkrzw_thread_util.h>

Public Member Functions

 Waiter (SignalBroker *broker)
 Constructor. More...
 
 ~Waiter ()
 Destructor. More...
 
bool Wait (double timeout=-1)
 Waits for a signal to happen. More...
 

Detailed Description

Handler to wait for the signal.

The constructor should be called before checking the resource. Then, the Wait method should be called if the resource state doesn't satisfy the required condition.

Constructor & Destructor Documentation

◆ Waiter()

tkrzw::SignalBroker::Waiter::Waiter ( SignalBroker broker)
explicit

Constructor.

Parameters
brokerThe broker object.

◆ ~Waiter()

tkrzw::SignalBroker::Waiter::~Waiter ( )

Destructor.

Member Function Documentation

◆ Wait()

bool tkrzw::SignalBroker::Waiter::Wait ( double  timeout = -1)

Waits for a signal to happen.

Parameters
timeoutThe timeout in seconds to wait. Zero means no wait. Negative means unlimited.
Returns
True if successful or false on timeout.

This detects only signals which happen during this method is running. In other words, signals which were sent before the call are not ignored.