Add ExecutionContext: cancellation + progress for boolean evaluation#41
Merged
Conversation
Binds the upstream `ManifoldExecutionContext` C API surface added in manifold's master post-v3.4.1 (`5f95a3a`) and now natively supported in the wasm-uu lane via shim v0.4.0-alpha.1 (PR #40). Why it matters: manifold operations are lazy. Building a CSG tree is cheap; the actual evaluation runs when something queries the result (num_tri, mesh extraction, status). For nontrivial trees this can be seconds to minutes, and there was previously no way to cooperatively abort it. ExecutionContext fixes that — pass it to a new `status_with_context` method and another thread can `cancel()` it. Use case examples: - Web demos / interactive UIs: cancel a stale boolean when the user changes inputs. - Server-side: timeout long-running ops without dropping the worker. - Batch processing: progress observation for status reporting. C API surface added (10 items in manifold-csg-sys): - `ManifoldExecutionContext` opaque type - 4 lifecycle: `_size`, `_alloc`, `_destruct`, `_delete` - 1 constructor: `manifold_execution_context(mem)` - 3 control: `_cancel`, `_cancelled`, `_progress` - 1 cancellable trigger: `manifold_status_with_context` Safe wrapper (manifold-csg): - New `execution` module with `ExecutionContext` struct (`Send + Sync`, justified by upstream's "safe to read/write from any thread" guarantee in the C header). - Methods: `new()`, `cancel()`, `is_cancelled()`, `progress()`, `Drop`. - `Manifold::status_with_context(&self, &ExecutionContext) -> ManifoldError` for the cancellable evaluation trigger. - 5 integration tests: initial state, sticky cancel, cross-thread cancel via Arc, status_with_context happy path, status_with_context with already-cancelled context. - API_COVERAGE.md updated with a new "Execution Context" section. Verified end-to-end: - 219 host integration tests pass (was 214; +5 new ExecutionContext) - wasm-uu CI-equivalent build clean; produced wasm has zero unexpected imports (confirms ExecutionContext links cleanly through the shim's v0.4.0-alpha.1 helper) - cargo fmt + cargo clippy clean Versions stay at 0.1.8 / 3.4.107 (pre-bumped by #40, this addition is additive so the bump still covers it).
bd158f0 to
e3af8c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Binds upstream's `ManifoldExecutionContext` (added post-v3.4.1, available on wasm-uu since shim v0.4.0-alpha.1 in #40). Lets another thread cancel a long-running boolean evaluation or observe its progress.
Surface (manifold-csg): `ExecutionContext::{new, cancel, is_cancelled, progress}` (`Send + Sync` per upstream's "safe to read/write from any thread" guarantee) + `Manifold::status_with_context(&ExecutionContext)` to trigger cancellable evaluation. `API_COVERAGE.md` updated.
Re upstream #1674 (within-phase cancel refactor): zero `bindings/c/` files touched, so our bindings stay accurate.
Versions stay at 0.1.8 / 3.4.107 (additive on top of #40's pre-bump).
Test plan