siplasplas
A library for C++ reflection and introspection
|
Implements an asynchronous signal sink suited for communication between different threads. More...
#include <siplasplas/signals/asyncsink.hpp>
Public Member Functions | |
template<typename Caller , typename Function > | |
AsyncSink (Caller &caller, Function function) | |
Creates an asynchronous sink given a caller and a destination function. More... | |
template<typename Caller , typename Callee , typename Function > | |
AsyncSink (Caller &caller, Callee &callee, Function function) | |
Creates an asynchronous sink given a caller, a callee, and a destination function. More... | |
bool | pull () override |
Checks whether there are queued signal emissions waiting to be handled and invokes the destination function for each of them. More... | |
Public Member Functions inherited from cpp::SignalSink | |
template<typename Caller , typename Callee > | |
SignalSink (Caller &caller, Callee &callee) | |
Constructs a sink given the connection caller and the callee. More... | |
template<typename Caller > | |
SignalSink (Caller &caller) | |
Constructs a sink given the connection caller object. More... | |
template<typename... Args> | |
void | operator() (Args &&...args) |
Invokes the sink with the given arguments. More... | |
SignalEmitter * | callee () const |
Gives the callee of the connection. More... | |
SignalEmitter * | caller () const |
Gives the caller of the connection. More... | |
Protected Member Functions | |
void | invoke (const std::vector< cpp::dynamic_reflection::Object > &args) override |
bool | invokeWithoutCallee () const override |
Implements an asynchronous signal sink suited for communication between different threads.
The AsyncSink class implements a sink that by default enqueues signal emissions in a thread safe queue. The destination function is invoked only when the user asks for incomming signals by pulling the sink. See AsyncSInk::pull().
|
inline |
Creates an asynchronous sink given a caller and a destination function.
See SignalEmitter::connect_async()
caller | Caller object. |
function | Function to be invoked when the signal is handled. |
|
inline |
Creates an asynchronous sink given a caller, a callee, and a destination function.
See SignalEmitter::connect_async()
caller | Caller object. |
callee | Callee object. |
function | Function to be invoked when the signal is handled. |
|
overridevirtual |
Checks whether there are queued signal emissions waiting to be handled and invokes the destination function for each of them.
The AsyncSink::pull() method fetches pending signals emissions (That is, argument sets from previous signal emissions from the caller object) and invokes the destination function using that arguments, once for each arguments set in the queue. This function continues invoking the destination function until the queue is empty. The destination function is executed from the same thread pull() was invoked.
Implements cpp::SignalSink.