Skip to main content

Jobs & Workers

Slow work (probing files, reading OTIO, scanning folders, exporting) runs off the host thread. Each start call returns a JobId. The outcome comes back as a SessionEvent from Session::tick(), which the host calls on its own thread, so results reach the project only there, as ordinary history steps.

session-job-lifecycle.png

Rules

  • Waker. Workers call Waker::wake() when there is something to collect. The host decides what that means: an egui repaint in the editor, an inbox wake for headless MCP.
  • Not inside an undo group. tick() turns imports and relinks into history steps, so it must not run while the caller has an undo group open (for example mid-gesture), or the results would join the user's step.
  • Undoable imports. An import's media all land in one undo step that can keep growing (join_import), for example with the timeline created for the first media.

Job kinds

JobThreads and behaviour
Media importImportWorker: one probe thread per core (probing a video takes ~100 ms). Results go into the pool in selection order, not completion order. Imports queue behind each other; files already in the pool are skipped (canonical paths).
OTIO importOne thread reads and probes. If imported media share a file name with pool media, the job waits for the host's decision (finish_otio_import: reuse, import all, or drop).
RelinkOne thread, by name under a folder or with files already chosen. All relinks form one undo step. Cancellable.
Forced relink searchStarted by the dialog (forced_relink::spawn_search). Matches files on the chosen criteria (duration, size, codec, waveform…) regardless of name.
ExportOne thread on a clone of the project, so editing can go on; see Export Pipeline. Progress stays readable after it ends.

Only one OTIO import, one relink and one export can run at a time; starting a second one returns None.

Worker<J>

vv_session::worker::Worker is the small building block for serial job queues: a thread reading an mpsc channel. Dropping it closes the queue and joins the thread. The app's proxy, waveform, thumbnail and mix-buffer workers are built on it.