|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Lightweight push-only event emitter. More...
#include <jh/asynchronous/slot.h>
Public Member Functions | |
| void | connect (listener< T > *l) noexcept |
| Connect this signal to a listener. | |
| template<typename... Args> | |
| bool | emit (Args &&... args) |
| Emit a value to the connected listener. | |
Lightweight push-only event emitter.
An event_signal provides a user-facing injection mechanism. It does not store or buffer events. It only forwards emit() into its connected listener.
event_signal can have a shorter lifespan than the connected listener, but it cannot have a longer lifespan (dangling). In particular, after a slot coroutine switches the listening object between different states, the event_signal can be recycled by running out of scope.
connect(listener*) must be called before the first emit(). emit() must be called after the slot has been spawned. emit(...) delegates synchronously to listener.invoke(). | T | Payload type. |
event_signal never performs fan-out nor routing. All routing, filtering, switching and fan-out are handled inside the slot coroutine.listener it is connected to.
|
inlinenoexcept |
Connect this signal to a listener.
The signal will deliver emitted events to this listener.
| l | Pointer to the listener. |
|
inline |
Emit a value to the connected listener.
Invokes listener's inbox delivery logic with constructed value.
| Args | Constructor arguments for T. |
| args | Arguments to construct the value. |