Skip to main content

Module pipeline

Module pipeline 

Source
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:

  1. copies all of them to subscription channels (subscribe),
  2. 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_any hooks. The processing loop (push) does not wait for hooks. Arrival order is preserved within a lane, so order within a kind is always preserved. (The on_any lane preserves the overall order.) The execution order between different kinds is not guaranteed.
  • Synchronous (sync(true)): hooks run immediately on the thread that called push, in event order (for each event, hooks of its kind first, then on_any hooks). 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§

Pipeline
Event driver that wraps a reducer.
Summary
Summary returned by finish.

Enums§

QueuePolicy
Per-kind queue policy.

Traits§

Reducer
The reducer driven by the pipeline.