Tkrzw
Classes | Public Member Functions | Friends | List of all members
tkrzw::SlottedKeySignalBroker< KEYTYPE > Class Template Referencefinal

Slotted broker to send a signal associated with a key to another thread. More...

#include <tkrzw_thread_util.h>

Classes

class  Waiter
 Handler to wait for the signal. More...
 

Public Member Functions

 SlottedKeySignalBroker (int32_t num_slots)
 Default constructor. More...
 
 ~SlottedKeySignalBroker ()
 Default constructor. More...
 
bool Send (const KEYTYPE &key, bool all=true)
 Sends a signal identified by a key. More...
 

Friends

class Waiter
 

Detailed Description

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

Slotted broker to send a signal associated with a key to another thread.

Constructor & Destructor Documentation

◆ SlottedKeySignalBroker()

template<typename KEYTYPE >
tkrzw::SlottedKeySignalBroker< KEYTYPE >::SlottedKeySignalBroker ( int32_t  num_slots)
explicit

Default constructor.

Parameters
num_slotsThe number of slots.

◆ ~SlottedKeySignalBroker()

template<typename KEYTYPE >
tkrzw::SlottedKeySignalBroker< KEYTYPE >::~SlottedKeySignalBroker

Default constructor.

Parameters
num_slotsThe number of slots.

Member Function Documentation

◆ Send()

template<typename KEYTYPE >
bool tkrzw::SlottedKeySignalBroker< KEYTYPE >::Send ( const KEYTYPE &  key,
bool  all = true 
)

Sends a signal identified by a key.

Parameters
keyThe key of the signal.
allIf true, notification is sent to all waiting threads. If false, it is sent to only one waiting thread.
Returns
True if the signal is received by an waiting thread, or false if not.