Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
feed::impl::TrackableSignal< Session, Args > Class Template Reference

A thread-safe class to manage a signal and its tracking connections. More...

#include <TrackableSignal.hpp>

Public Member Functions

bool connectTrackableSlot (ConnectionSharedPtr const &trackable, std::function< void(Args...)> slot)
 Connect a slot to the signal, the slot will be called when the signal is emitted and trackable is still alive.
 
bool disconnect (ConnectionPtr trackablePtr)
 Disconnect a slot to the signal.
 
void emit (Args const &... args) const
 Calling all slots.
 
std::size_t count () const
 Get the number of connections.
 

Detailed Description

template<typename Session, typename... Args>
class feed::impl::TrackableSignal< Session, Args >

A thread-safe class to manage a signal and its tracking connections.

Parameters
SessionThe type of the object that will be tracked, when the object is destroyed, the connection will be removed lazily. The pointer of the session object will also be the key to disconnect.
ArgsThe types of the arguments that will be passed to the slot.

Member Function Documentation

◆ connectTrackableSlot()

template<typename Session , typename... Args>
bool feed::impl::TrackableSignal< Session, Args >::connectTrackableSlot ( ConnectionSharedPtr const & trackable,
std::function< void(Args...)> slot )
inline

Connect a slot to the signal, the slot will be called when the signal is emitted and trackable is still alive.

Parameters
trackableTrack this object's lifttime, if the object is destroyed, the connection will be removed lazily. When the slot is being called, the object is guaranteed to be alive.
slotThe slot connecting to the signal, the slot will be called when the signal is emitted.
Returns
true if the connection is successfully added, false if the connection already exists.

◆ disconnect()

template<typename Session , typename... Args>
bool feed::impl::TrackableSignal< Session, Args >::disconnect ( ConnectionPtr trackablePtr)
inline

Disconnect a slot to the signal.

Parameters
trackablePtrDisconnect the slot whose trackable is this pointer. Be aware that the pointer is a raw pointer, allowing disconnect to be called in the destructor of the trackable.
Returns
true if the connection is successfully disconnected, false if the connection does not exist.

◆ emit()

template<typename Session , typename... Args>
void feed::impl::TrackableSignal< Session, Args >::emit ( Args const &... args) const
inline

Calling all slots.

Parameters
argsThe arguments to pass to the slots.

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