Skip to main content

Module workers

Module workers 

Source
Expand description

Async worker pool: WorkerMsg enum, spawn/dispatch helpers, mpsc plumbing.

The terminal panel’s session threads report on the same channel (TerminalOutput, TerminalExited), though they are OS threads rather than pool tasks — see crate::terminal::session.

Workers do anything that could be slow (git status, filesystem watching, syntax highlighting, image decoding) and report results back to the UI thread over a single mpsc channel drained once per UI tick.

Architecture contract (§4 of trail_architecture.md):

  • Every task sends its result as a WorkerMsg over the shared Sender.
  • Every WorkerMsg::Preview / WorkerMsg::ImageMeta carries the generation it was spawned for; merge() compares it against state.preview.generation and drops the message if they don’t match.
  • Workers never touch ratatui/crossterm state directly.

Re-exports§

pub use git::GitCache;

Modules§

fswatch
Filesystem watcher.
git
Git status worker.
highlight
Syntax highlighting worker.
image_decode
Image decoding worker.

Enums§

WorkerMsg
All messages that worker tasks can send back to the UI thread.

Functions§

channel
Creates the bounded (Sender, Receiver) pair used between the worker pool and the UI thread.
merge
Applies a WorkerMsg to state, enforcing the generation-guard for preview-related messages.