Async 1.8.0
|
A threadsafe SigC signal. More...
#include <AsyncThreadSigCSignal.h>
Public Types | |
enum | Mode { NON_SYNCHRONOUS , SYNCHRONOUS } |
typedef T_ret | result_type |
typedef sigc::slot< T_ret, Args... > | slot_type |
typedef sigc::slot_list< slot_type > | slot_list_type |
typedef sigc::signal< T_ret, Args... > | signal_type |
typedef signal_type::iterator | iterator |
typedef signal_type::const_iterator | const_iterator |
Public Member Functions | |
ThreadSigCSignal (Mode mode=NON_SYNCHRONOUS) | |
Constructor. | |
ThreadSigCSignal (const ThreadSigCSignal &)=delete | |
The copy constructor is deleted. | |
~ThreadSigCSignal (void) | |
Destructor. | |
ThreadSigCSignal & | operator= (const ThreadSigCSignal &)=delete |
The assignment operator is deleted. | |
iterator | connect (const slot_type &slt) |
Connect this signal to the given slot. | |
template<typename... T> | |
result_type | emit (T &&... args) |
Queue the emission of this signal. | |
template<typename... T> | |
result_type | emit_reverse (T &&... args) |
Queue the emission of this signal in reverse order. | |
template<typename... T> | |
result_type | operator() (T &&... args) |
Queue the emission of this signal. | |
slot_type | make_slot (void) |
Return a slot that emits this signal. | |
slot_list_type | slots (void) |
Return a list of the connected slots. | |
const slot_list_type | slots (void) const |
Return a list of the connected slots. | |
A threadsafe SigC signal.
This class is implemented as close as possible to mimic a sigc::signal but with thread safety in mind. When the signal is emitted, instead of calling it directly, it will be added to a queue. The queue is then processed from the Async main thread in a safe manner so that all connected slots are called from the main thread.
There also is a synchrorous mode where the queue is not used and the connected slot is called directly after grabbing an Async::Mutex lock. The negative side of using synchronous mode is that all threads wanting to grab an Async::Mutex will block until the signal emission processing have finished. It probably is best to not use synchronous mode in most cases. One case where synchronouns mode have to be used is if the return value of the connected slot(s) is important since the non-synchronous mode cannot provide the signal emitter with the return value from the connected slot(s).
If the signal is emitted from the main Async thread it will still be queued so this may be used if a signal emission need to be delayed so that it is called from the main Async loop. Note that if synchronous mode has been activated the queue will not be used and the signal will behave like a normal sigc::signal.
Definition at line 140 of file AsyncThreadSigCSignal.h.
signal_type::const_iterator Async::ThreadSigCSignal< T_ret, Args >::const_iterator |
Definition at line 148 of file AsyncThreadSigCSignal.h.
signal_type::iterator Async::ThreadSigCSignal< T_ret, Args >::iterator |
Definition at line 147 of file AsyncThreadSigCSignal.h.
T_ret Async::ThreadSigCSignal< T_ret, Args >::result_type |
Definition at line 143 of file AsyncThreadSigCSignal.h.
sigc::signal<T_ret, Args...> Async::ThreadSigCSignal< T_ret, Args >::signal_type |
Definition at line 146 of file AsyncThreadSigCSignal.h.
sigc::slot_list<slot_type> Async::ThreadSigCSignal< T_ret, Args >::slot_list_type |
Definition at line 145 of file AsyncThreadSigCSignal.h.
sigc::slot<T_ret, Args...> Async::ThreadSigCSignal< T_ret, Args >::slot_type |
Definition at line 144 of file AsyncThreadSigCSignal.h.
enum Async::ThreadSigCSignal::Mode |
Enumerator | |
---|---|
NON_SYNCHRONOUS | |
SYNCHRONOUS |
Definition at line 150 of file AsyncThreadSigCSignal.h.
|
inline |
Constructor.
mode | Choose mode of operation |
If SYNCHRONOUS mode is set, when the signal is emitted it will not be queued but rather the connected slot will be called directly after grabbing an Async::Mutex lock. THe default is non-synchronous mode where the signal emission is queued.
Definition at line 161 of file AsyncThreadSigCSignal.h.
|
delete |
The copy constructor is deleted.
|
inline |
Destructor.
Definition at line 171 of file AsyncThreadSigCSignal.h.
References Async::TaskRunner::cancel().
|
inline |
Connect this signal to the given slot.
slt | The slot to connect to |
Definition at line 188 of file AsyncThreadSigCSignal.h.
|
inline |
Queue the emission of this signal.
arg | Zero or more arguments depending on the signal declaration |
This function will add a signal emission to the emission queue. Since the emission is delayed there is no way of returning the return value from the slot(s). This function will instead return the default value of the specified return type.
Definition at line 204 of file AsyncThreadSigCSignal.h.
|
inline |
Queue the emission of this signal in reverse order.
arg | Zero or more arguments depending on the signal declaration |
This function will add a signal emission to the emission queue. Since the emission is delayed there is no way of returning the return value from the slot(s). This function will instead return the default value of the specified return type. The connected slots will be called in the reverse order in comparison to the order they were added.
Definition at line 222 of file AsyncThreadSigCSignal.h.
|
inline |
Return a slot that emits this signal.
Definition at line 247 of file AsyncThreadSigCSignal.h.
|
inline |
Queue the emission of this signal.
arg | Zero or more arguments depending on the signal declaration |
This function will add a signal emission to the emission queue. Since the emission is delayed there is no way of returning the return value from the slot(s). This function will instead return the default value of the specified return type.
Definition at line 238 of file AsyncThreadSigCSignal.h.
|
delete |
The assignment operator is deleted.
|
inline |
Return a list of the connected slots.
Definition at line 256 of file AsyncThreadSigCSignal.h.
|
inline |
Return a list of the connected slots.
Definition at line 265 of file AsyncThreadSigCSignal.h.