BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlmt::Signaler< t_PROT > Class Template Reference

#include <bdlmt_signaler.h>

Inheritance diagram for bdlmt::Signaler< t_PROT >:
bdlmt::Signaler_Invocable< Signaler< t_PROT >, t_PROT >

Public Types

typedef void ResultType
 

Public Member Functions

 Signaler (bslma::Allocator *basicAllocator=0)
 
 ~Signaler ()
 
template<class t_FUNC >
SignalerConnection connect (BSLS_COMPILERFEATURES_FORWARD_REF(t_FUNC) slot, int group=0)
 
void disconnectAllSlots () BSLS_KEYWORD_NOEXCEPT
 
void disconnectAllSlotsAndWait () BSLS_KEYWORD_NOEXCEPT
 
void disconnectGroup (int group) BSLS_KEYWORD_NOEXCEPT
 
void disconnectGroupAndWait (int group) BSLS_KEYWORD_NOEXCEPT
 
bsl::size_t slotCount () const
 

Friends

struct Signaler_Invocable< Signaler< t_PROT >, t_PROT >
 

Detailed Description

template<class t_PROT>
class bdlmt::Signaler< t_PROT >

This class template provides a thread-safe signaler that executes connected slots when invoked via its call operator. t_PROT is a function signature and must have a return type of void. The callable objects assigned to the slots may have return types other than void, in which case their return values will be discarded.

See bdlmt_signaler

Member Typedef Documentation

◆ ResultType

template<class t_PROT >
typedef void bdlmt::Signaler< t_PROT >::ResultType

Constructor & Destructor Documentation

◆ Signaler()

template<class t_PROT >
bdlmt::Signaler< t_PROT >::Signaler ( bslma::Allocator basicAllocator = 0)
explicit

Create a Signaler object having no connected slots. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the supplied allocator must remain valid until all connection objects associated with this signaler are destroyed.

◆ ~Signaler()

template<class t_PROT >
bdlmt::Signaler< t_PROT >::~Signaler ( )
inline

Destroy this object. Call disconnectAllSlots(). The behavior is undefined if this function is invoked from a slot connected to this signaler.

Member Function Documentation

◆ connect()

template<class t_PROT >
template<class t_FUNC >
SignalerConnection bdlmt::Signaler< t_PROT >::connect ( BSLS_COMPILERFEATURES_FORWARD_REF(t_FUNC)  slot,
int  group = 0 
)
inline

Connect the specified slot, a callable object which must meet the Slot Object Requirements described in the component documentation, to this signaler. Optionally specify a group used to order slots upon invocation. Return an instance of SignalerConnection representing the created connection. This function meets the strong exception guarantee. Note that the connected slot may be called by a signal emitted from another thread before this function completes. Also note that it is unspecified whether connecting a slot while the signaler is emitting will result in the slot being called immediately. Note that t_FUNC may have a return type other than void, but in that case, when the slot is called, the return value will be discarded.

◆ disconnectAllSlots()

template<class t_PROT >
void bdlmt::Signaler< t_PROT >::disconnectAllSlots ( )
inline

Disconnect all slots, if any, connected to this signaler. Any signals emitted on the corresponding signaler that happen after this call to disconnect completes will not call any slots that were connected prior to this call. Throws nothing. Note that this function does not block the calling thread pending completion of ongoing signals emitted on the signaler. Also note that it is unspecified how many slots, if any, will be called by any invocation on the signaler that begins before this function completes. Also note that if a slot is connected to this signaler during a call to this function, it is unspecified whether that slot will be disconnected.

◆ disconnectAllSlotsAndWait()

template<class t_PROT >
void bdlmt::Signaler< t_PROT >::disconnectAllSlotsAndWait ( )
inline

Disconnect all slots, if any, connected to this signaler. Any signals emitted on the corresponding signaler that happens after this call to disconnect completes will not call any slots that were connected prior to this call. This function blocks the calling thread pending completion of all ongoing signals being emitted on the signaler. Throws nothing. The behavior is undefined if this method is called from a slot connected to the signaler. Note that it is unspecified how many slots, if any, will be called by any invocation on the signaler that begins before this function completes. Also note that if a slot is connected to this signaler during a call to this function, it is unspecified whether that slot will be disconnected.

◆ disconnectGroup()

template<class t_PROT >
void bdlmt::Signaler< t_PROT >::disconnectGroup ( int  group)
inline

Disconnect all slots, if any, connected to this signaler in the specified group. Any signal emitted on the corresponding signaler that happens after this call to disconnect completes will not call any slots in group that were connected prior to this call. Throws nothing. Note that this function does not block the calling thread pending completion of ongoing signals emitted on the signaler. Also note that it is unspecified how many affected slots, if any, will be signalled to by any invocation on the signaler that begins before this function completes. Also note that if a slot in group is connected to this signaler during a call to this function, it is unspecified whether that slot will be disconnected.

◆ disconnectGroupAndWait()

template<class t_PROT >
void bdlmt::Signaler< t_PROT >::disconnectGroupAndWait ( int  group)
inline

Disconnect all slots, if any, connected to this signaler in the specified group. Any signal emitted on the corresponding signaler that happens after this call to disconnect completes will not call any slots in group that were connected prior to this call. This function blocks the calling thread pending completion of ongoing signals being emitted on the signaler. Throws nothing. The behavior is undefined if this method is called from a slot connected to the signaler. Note that it is unspecified how many affected slots, if any, will be signaled to by any emission on the signaler that begins before this function completes. Also note that if a slot in group is connected to this signaler during a call to this function, it is unspecified whether that slot will be disconnected.

◆ slotCount()

template<class t_PROT >
bsl::size_t bdlmt::Signaler< t_PROT >::slotCount ( ) const
inline

Return the number of slots connected to this signaler. Note that the value returned by slotCount() is approximate if the signaler is being simultaneously manipulated by other threads.

Friends And Related Symbol Documentation

◆ Signaler_Invocable< Signaler< t_PROT >, t_PROT >

template<class t_PROT >
friend struct Signaler_Invocable< Signaler< t_PROT >, t_PROT >
friend

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