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
45
46
47
48
49
50
51
//! Cooperative cancellation for engine runs.
use ;
use Arc;
/// A cheap, thread-safe flag for cancelling an engine run.
///
/// The engine checks the token between batches and executors check it between
/// individual jobs, so cancelling takes effect at job granularity. Clone the
/// token to share it with passes (a pass may cancel a run itself) or with a
/// watchdog thread.
///
/// # Examples
///
/// ```
/// use increparse::CancelToken;
///
/// let token = CancelToken::new();
/// assert!(!token.is_cancelled());
///
/// let shared = token.clone();
/// shared.cancel();
/// assert!(token.is_cancelled());
///
/// token.reset();
/// assert!(!token.is_cancelled());
/// ```
;