|
template<typename Caller , typename Function , typename R , typename Class , typename... Args> |
static std::shared_ptr< const SignalSink > | connect (Caller &caller, R(Class::*source)(Args...), Function function) |
| Creates a direct connection from the given emitter object to the given function. More...
|
|
template<typename Caller , typename Callee , typename Function , typename R , typename Class , typename... Args> |
static std::shared_ptr< const SignalSink > | connect (Caller &caller, R(Class::*source)(Args...), Callee &callee, Function function) |
| Creates a direct connection from the given emitter object to the given function, using an specific callee object. More...
|
|
template<typename Caller , typename Function , typename R , typename Class , typename... Args> |
static std::shared_ptr< const SignalSink > | connect_async (Caller &caller, R(Class::*source)(Args...), Function function) |
| Creates an asynchronous connection between a signal and a function. More...
|
|
template<typename Caller , typename Callee , typename Function , typename R , typename Class , typename... Args> |
static std::shared_ptr< const SignalSink > | connect_async (Caller &caller, R(Class::*source)(Args...), Callee &callee, Function function) |
| Creates an asynchronous connection between a signal and a function using an specific callee object. More...
|
|
template<typename Caller , typename Callee , typename R , typename... Args> |
static std::shared_ptr< const SignalSink > | bypass (Caller &caller, R(Caller::*source)(Args...), Callee &callee, R(Callee::*dest)(Args...)) |
| Connects two signals synchronously. More...
|
|
template<typename Caller , typename Callee , typename R , typename... Args> |
static std::shared_ptr< const SignalSink > | bypass_async (Caller &caller, R(Caller::*source)(Args...), Callee &callee, R(Callee::*dest)(Args...)) |
| Connects two signals asynchronously. More...
|
|
template<typename Class , typename R , typename... FArgs, typename... Args> |
static void | emit (Class &emitter, R(Class::*function)(FArgs...), Args &&...args) |
| Emits a signal on the given emitter. More...
|
|
Class that can send and receive signals from other emitters.
This class manages mapping from signals to sinks (i.e. outgoing connectiong from this object) as well as incomming connections. All connections are closed when the caller (source object) or the callee (destination object, if there is) are destroyed.
For details
- See also
- Signals
- Examples:
- cmake/cmake-project.cpp.
template<typename Caller , typename Callee , typename R , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::bypass |
( |
Caller & |
caller, |
|
|
R(Caller::*)(Args...) |
source, |
|
|
Callee & |
callee, |
|
|
R(Callee::*)(Args...) |
dest |
|
) |
| |
|
inlinestatic |
Connects two signals synchronously.
This connection bypasses signals so there's no need to have an intermediary sink to link one signal to another. The connection is synchronous, so when the source signal is emitted, the destination signal is emitted directly, in the same thread.
- Parameters
-
caller | Emitter of the source signal. |
Caller::*source | Source signal. |
callee | Emitter of the destination signal. Could be the caller too. |
Callee::*dest | Destination signal. |
- Returns
- A shared pointer to the SYncSink implementing the connection.
template<typename Caller , typename Callee , typename R , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::bypass_async |
( |
Caller & |
caller, |
|
|
R(Caller::*)(Args...) |
source, |
|
|
Callee & |
callee, |
|
|
R(Callee::*)(Args...) |
dest |
|
) |
| |
|
inlinestatic |
Connects two signals asynchronously.
This connection bypasses signals so there's no need to have an intermediary sink to link one signal to another. The destination signal is invoked whenever the callee object is polled. The destination signal is emitted from the thread the callee ofject is polled.
- Parameters
-
caller | Emitter of the source signal. |
Caller::*source | Source signal. |
callee | Emitter of the destination signal. Could be the caller too. |
Callee::*dest | Destination signal. |
- Returns
- A shared pointer to the SYncSink implementing the connection.
template<typename Caller , typename Function , typename R , typename Class , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::connect |
( |
Caller & |
caller, |
|
|
R(Class::*)(Args...) |
source, |
|
|
Function |
function |
|
) |
| |
|
inlinestatic |
Creates a direct connection from the given emitter object to the given function.
Direct connections invoke the destination function just after the source signal is invoked. The destination function is invoked in the same thread the signal was emitted. This connections preserve caller affinity (The sink is invoked only if it was the caller object was who emitted the signal, not whenever any object emits the signal). Direct connections are implemented by registering instances of SyncSink on the caller object. The connection has no associated callee object, so there's no way to poll this connection except from the returned sink. Both source (The member function pointer representing the signal) and function must have the same signature.
- Parameters
-
caller | object the signal is raised from. |
Class::*source | Pointer to the class member function representing the signal. |
function | Function to be invoked when the signal is emitted. |
- Returns
- A shared pointer to the sink of the connection.
- Examples:
- fswatch/fswatch.cpp.
template<typename Caller , typename Callee , typename Function , typename R , typename Class , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::connect |
( |
Caller & |
caller, |
|
|
R(Class::*)(Args...) |
source, |
|
|
Callee & |
callee, |
|
|
Function |
function |
|
) |
| |
|
inlinestatic |
Creates a direct connection from the given emitter object to the given function, using an specific callee object.
Direct connections invoke the destination function just after the source signal is invoked. The destination function is invoked in the same thread the signal was emitted. This connections preserve caller affinity (The sink is invoked only if it was the caller object was who emitted the signal, not whenever any object emits the signal). Direct connections are implemented by registering instances of SyncSink on the caller object. The destination function has an associated callee object, so this connection could be polled directly from the callee object. If the destination function is a member function of the callee class, the function is invoked using callee. Both source (The member function pointer representing the signal) and function must have the same signature.
- Parameters
-
caller | object the signal is raised from. |
Class::*source | Pointer to the class member function representing the signal. |
Callee& | callee Destination object of the connection. |
function | Function to be invoked when the signal is emitted. |
- Returns
- A shared pointer to the sink of the connection.
template<typename Caller , typename Function , typename R , typename Class , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::connect_async |
( |
Caller & |
caller, |
|
|
R(Class::*)(Args...) |
source, |
|
|
Function |
function |
|
) |
| |
|
inlinestatic |
Creates an asynchronous connection between a signal and a function.
Asynchronous connections are connections that don't directly invoke the destination function when the signal is invoked but delay the invocation until the user explicitly polls the connection. See SignalEmitter::poll() and SignalSink::poll(). Async connections are implemented by means of the AsyncSink class, which enqueues invocations on a thread-safe queue and deques and invokes the destination function when the connection is polled. Async connections are designed for inter-thread communication, where one thread acts as producer (invokes/emits the signal) and thread other consumes the connection (explicitly polls the connection). Please consider using direct connections by default and use async connections only as a communication bridge between two threads.
The destination function has no associated callee object, so the connection can be polled through the returned sink only. The destination function is executed in the same thread the connection is polled.
- Parameters
-
caller | Object the signal is raised from. |
Class::*source | Pointer to the class member representing the signal. |
function | Function to be invoked when the connection is polled (See details). |
- Returns
- A shared pointer to the connection sink.
- Examples:
- cmake/cmake-project.cpp, and signals/signals.cpp.
template<typename Caller , typename Callee , typename Function , typename R , typename Class , typename... Args>
static std::shared_ptr<const SignalSink> cpp::SignalEmitter::connect_async |
( |
Caller & |
caller, |
|
|
R(Class::*)(Args...) |
source, |
|
|
Callee & |
callee, |
|
|
Function |
function |
|
) |
| |
|
inlinestatic |
Creates an asynchronous connection between a signal and a function using an specific callee object.
(For details on async connections in general, see SignalEmitter::connect_async(caller, source, function) details).
This connection has an asociated callee object. SignalEmitter objects have a SignalEmitter::poll() function that polls all the connections comming to it (i.e. all connections which the object is acting as callee). The destination function is executed in the same thread the connection is polled.
- Parameters
-
caller | Object the signal is raised from. |
Class::*source | Pointer to the class member representing the signal. |
function | Function to be invoked when the connection is polled (See details). |
- Returns
- A shared pointer to the connection sink.