1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! 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.
use Arc;
use ;
/// A shareable, thread-safe cancellation flag.
///
/// `clone()` is cheap (an `Arc` bump) — hand one clone to the search config
/// and keep another on the calling side to flip when a timeout elapses.
;