Skip to main content

Module cancel

Module cancel 

Source
Expand description

Cooperative cancellation token.

A cheap, Clone-able flag checked at the same cadence as crate::SolveConfig::node_budget inside every search loop (solver::backtrack, solver::backjump, solver::optimize). Unlike the node budget — which is an internal, self-imposed cap — this is an external signal: a caller (e.g. the PyO3 boundary, on behalf of an asyncio.wait_for timeout) can flip it from another thread while the search is running on a Python::allow_threads-released worker thread, and the next node-budget-cadence check will unwind the recursion cleanly.

Deliberately not the same flag/field as budget_exceeded — the two are distinct outcomes (self-imposed cap vs. externally requested stop) and collapsing them would repeat the exact “conflated failure modes” mistake flagged elsewhere in this codebase’s own solve-result plumbing.

Structs§

CancelToken
A shareable, thread-safe cancellation flag.