Expand description
Closure hook pipeline (Pipeline): hook registration, queues, policies, panic isolation, channels.
It wraps a reducer (Reducer), pushes inputs into it, and for the events the reducer emits:
- copies all of them to subscription channels (
subscribe), - passes them to the registered hooks (
on,on_any, …).
How hooks run
- Asynchronous (default): hooks run on “lane” worker threads. There is one lane per event kind
and one lane for
on_anyhooks. The processing loop (push) does not wait for hooks. Arrival order is preserved within a lane, so order within a kind is always preserved. (Theon_anylane preserves the overall order.) The execution order between different kinds is not guaranteed. - Synchronous (
sync(true)): hooks run immediately on the thread that calledpush, in event order (for each event, hooks of its kind first, thenon_anyhooks). For tests and file output.
The queue policy (policy) is set per kind. The default is to keep everything (QueuePolicy::KeepAll).
For kinds where only the latest matters, such as display updates, earlier unprocessed events can be dropped.
If a hook panics, it is caught with catch_unwind, an Event::Error is sent to subscribers, and the pipeline keeps running.
(That Error is not delivered to hooks, to prevent an error hook from panicking again and looping forever.)
Structs§
Enums§
- Queue
Policy - Per-kind queue policy.
Traits§
- Reducer
- The reducer driven by the pipeline.