- SignalProto< Signature, Collector >
- cinder::signals::Signal
Signal is a template type providing an interface for arbitrary callback lists.
A signal type is declared with the function signature of its callbacks, and optionally a return result collector class type. The callbacks of a signal are invoked with the emit() method and arguments according to the signature.
The result returned by emit() depends on the signal collector class. By default, the result of the last callback is returned from emit(). Collectors can be implemented to accumulate callback results or to halt the running emissions in correspondance to callback results.
You can control the order in which callbacks are connected by providing a
priority
int as the first argument to connect(). A higher priority means the callback will happen sooner in the emission chain. Callbacks within the same emission group will be called according to the order they were connected, first in first out. By default all connected slots will be assigned to the priority group
0
, e.g. you call connect() with no
priority
argument. This also means by default, when no priority groups are used then whatever callback is connected first to a signal will be called first.
To disconnect a slot, you use the Connection class returned from the connect() methods. You can also capture a ScopedConnection from connect(), which will automatically disconnect when it goes out of scope.
The signal implementation is safe against recursion, so callbacks may be connected and disconnected during a signal emission. Recursive emit() calls are also safe.
Signals are non-copyable.