Observe and control a long-running Manifold evaluation. More...
#include <common.h>
Public Member Functions | |
| ExecutionContext (const ExecutionContext &) | |
| ExecutionContext (ExecutionContext &&) noexcept | |
| ExecutionContext & | operator= (const ExecutionContext &) |
| ExecutionContext & | operator= (ExecutionContext &&) noexcept |
| void | Cancel () |
| Request cancellation. Can be called from any thread. Idempotent. | |
| bool | Cancelled () const |
| Has cancellation been requested? | |
| double | Progress () const |
Public Attributes | |
| std::shared_ptr< Impl > | impl_ |
Observe and control a long-running Manifold evaluation.
Attach to a Manifold via Manifold::WithContext(ctx); the next eager op invoked on the result (Status, Refine / RefineToLength / RefineToTolerance, Hull, MinkowskiSum / MinkowskiDifference) snapshots the ctx and reports progress and observes cancellation through it. Safe to read/write from any thread.
Copyable and movable: copies share the same underlying state via a shared_ptr, so one thread can evaluate while another holds a copy and observes Progress() or calls Cancel(). Use a separate context per evaluation; passing the same context (or a copy of it) to two concurrent eager ops produces meaningless progress values because both calls reset and mutate the same counters.
Cancellation is permanent for a Manifold: once requested and detected, the Manifold's status becomes Error::Cancelled and stays Cancelled. To retry, construct a new Manifold. A context, however, is reusable: each evaluation through it resets the progress counters, but it does NOT clear the cancel flag – once Cancel() has been called on a context, every subsequent evaluation with that context (or any copy of it) will short-circuit to Error::Cancelled. Construct a fresh context to make a new evaluation cancellable independently.
Cancellation granularity varies by op: Boolean trees check per sub-boolean (so a single very large boolean may run to completion before the next check); Hull checks at the boundaries of its main phases (post-buildMesh and post-SortGeometry); Minkowski checks per face of the first input and per internal BatchBoolean batch.
Example: cancel a long-running BatchBoolean from an observer thread.
Example: cancel a Minkowski sum mid-evaluation.
| double Progress | ( | ) | const |
Normalized progress in [0, 1]. Monotonically increases during evaluation. Returns 1.0 when no work has been scheduled (interpreted as trivially complete – e.g. a single-leaf manifold has nothing to evaluate, and Progress() called before any Status(ctx) reflects the same "no pending work" state).