Expand description
Background jobs: progress, cancel, panic isolation, apply-on-UI-thread.
A job runs on a worker thread with a snapshot of what it needs (moved in: an Arc of the
document, a path…). It reports progress through Progress, stops when its CancelToken is
cancelled, and runs under catch_unwind. It finishes with an Apply: a closure the UI thread
runs on the app state when Jobs::drain_ready sees it (each frame, or when the wake hook
asked for one). That is where the document is edited, as one undo step.
Jobs::list / Jobs::to_json describe every job for the progress panel and for agents.
On wasm32 jobs run inline (no threads); long work there uses Jobs::spawn_stepped, which
drain_ready advances a few steps per frame.
Structs§
- Cancel
Token - Cooperative cancellation: the job checks it (or the
boolits progress calls return). - JobBuilder
- A job being described (
Jobs::job): how it runs, then one of thespawnmethods starts it. - JobId
- A job’s id, unique within one
Jobs. - JobInfo
- One row of the progress panel /
jobs.list. - JobRecord
- A finished job (kept for the progress panel and agents).
- Jobs
- The background jobs of one app state
S. - Progress
- Handed to a running job: report progress, check for cancellation.
- Ready
- What
Jobs::take_readytook: finished jobs and partial results, in order, to apply. - Updates
- Sends partial results from a running job (
JobBuilder::spawn_streaming): each one is applied on the UI thread by the nextJobs::drain_ready, in the order sent, while the job goes on (keyframes as a tracker finds them, hits as a search finds them). Updates sent before the job finished are applied even when it was cancelled; an update that fails to apply cancels its job, the failure becomes the job’s message and later updates are dropped.
Enums§
Functions§
- apply
- Box an apply closure.