Skip to main content

proef_core/
cancel.rs

1//! Cooperative cancellation plumbing (ADR-0007).
2//!
3//! Cancellation is cooperative at **batch boundaries**: the orchestrator checks the
4//! token before opening sessions and before each batch; engines receive it through
5//! [`crate::engine::EngineSession::run_batch`] and may honor it at finer grain when
6//! they can. The token is re-exported here so engines and the CLI share one type
7//! without depending on `tokio-util` directly — it is runtime-agnostic (no tokio
8//! runtime enters the dependency tree; `default-features = false`).
9
10pub use tokio_util::sync::CancellationToken;
11
12#[cfg(test)]
13mod tests {
14    use super::CancellationToken;
15
16    /// Polling and child tokens work from plain threads (ADR-0007 verified fact —
17    /// kept as a pinned regression against tokio-util changes).
18    #[test]
19    fn token_polls_and_propagates_to_children_without_a_runtime() {
20        let root = CancellationToken::new();
21        let child = root.child_token();
22        assert!(!child.is_cancelled());
23        root.cancel();
24        assert!(child.is_cancelled());
25    }
26}