Skip to main content

Module progress

Module progress 

Source
Expand description

Progress reporting and cancellation for long operations.

A caller who starts a tessellation, a boolean or an import may need to stop it (a user closed the dialog) or to show that it is alive. The kernel’s answer is a Watch: install one around a call with watched, hand its Canceller to whoever may pull the plug, and every long loop inside the kernel calls checkpoint at its own boundaries. A cancelled checkpoint returns OgeomError::Cancelled, which unwinds as an ordinary error; no partial result pretends to be whole.

The watch travels implicitly, by scope: operations keep their signatures, and code that never installs a watch pays one thread-local read per checkpoint. Worker threads a kernel operation spawns re-install the caller’s watch through snapshot/with_snapshot, so cancellation reaches into parallel stages too.

Cancellation is cooperative and prompt rather than immediate: it lands at the next checkpoint, and checkpoints sit at stage and item boundaries, never inside an invariant-restoring section.

Structs§

Canceller
The stop button: cancel from any thread, any number of times.
Stage
A stage announcement: the name, and where the operation stands in it when the operation knows.
Watch
A scope’s progress watch: cancellation flag plus an optional sink that receives stage names as the operation passes them.
WatchSnapshot
An opaque, cloneable capture of the active watch.

Functions§

checkpoint
The point a long loop offers for cancellation. Free when no watch is installed.
snapshot
The active watch, portable to a worker thread. None when unwatched.
stage
Announce a stage boundary to the active watch’s sink, if there is one.
stage_at
Announce a stage with its position: done of total items complete. What a determinate progress bar is built from; emitted by the operations that know both numbers: a reader over its solids, a tessellation over its faces.
watched
Run f with watch active on this thread: every checkpoint inside answers to it. Scopes nest; the inner watch wins until it ends.
with_snapshot
Run f under a snapshot taken on another thread: how a parallel stage keeps answering the caller’s watch.