Tkrzw
Public Member Functions | List of all members
tkrzw::SlottedKeySignalBroker< KEYTYPE >::Waiter Class Reference

Handler to wait for the signal. More...

#include <tkrzw_thread_util.h>

Public Member Functions

 Waiter (SlottedKeySignalBroker< KEYTYPE > *broker, const KEYTYPE &key)
 Constructor. More...
 
bool Wait (double timeout=-1)
 Waits for a signal to happen. More...
 

Detailed Description

template<typename KEYTYPE>
class tkrzw::SlottedKeySignalBroker< KEYTYPE >::Waiter

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()

template<typename KEYTYPE >
tkrzw::SlottedKeySignalBroker< KEYTYPE >::Waiter::Waiter ( SlottedKeySignalBroker< KEYTYPE > *  broker,
const KEYTYPE &  key 
)

Constructor.

Parameters
brokerThe broker object.
keyThe key of the signal.

Member Function Documentation

◆ Wait()

template<typename KEYTYPE >
bool tkrzw::SlottedKeySignalBroker< KEYTYPE >::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.