Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Async, Concurrency, and Priorities

Watchexec::with_config creates one bounded priority event channel and spawns action, filesystem, signal, keyboard, and error workers in a Tokio JoinSet. A Notify start lock allows construction and configuration before those workers begin.

The action worker is deliberately serial: one event batch becomes one policy decision at a time. An async action handler is awaited in that loop, so a slow handler delays event consumption. The API documents this rather than implying unbounded handler concurrency is safe.

Job tasks provide the independent concurrency. Each owns one process state machine and receives controls through normal, high, and urgent queues. During a graceful-stop timer, normal controls are excluded while high/urgent controls and timer expiry remain selectable.

concurrent producers → bounded priority channel → serial decisions
                                                   ↓
                                  independent job supervisor tasks

This separates concurrency from ordering: sources may race, policy is ordered, and unrelated children can progress independently. LateJoinSet additionally keeps spawned job tasks attached to shutdown even if they finish before the owner begins joining them.