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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Mike Grier
//! Suppressing a callback's re-arm while a teardown is in progress.
//!
//! Shared by `ThreadpoolWait` and `ThreadpoolTimer`, which had separate and
//! near-identical copies of this until `M-T4.10`. It is the mechanism [teardown
//! drains rather than cancels](../../../DESIGN-NOTES.md#teardown-drains) rests
//! on: without it a drain can return with the object armed again, and for
//! `Drop` that means closing the object and freeing its context with a fresh
//! callback queued against them.
use ;
/// How many callers are currently suppressing re-arming: zero means allowed.
///
/// # Why a count and not a flag
///
/// Suppression has two users with different lifetimes. `stop_and_drain` raises
/// it and lowers it again, because the object stays usable afterwards; `Drop`
/// raises it permanently, because there is no afterwards. With a flag, a
/// `stop_and_drain` finishing would clear a suppression that a concurrent one --
/// or a `Drop` -- still needed.
///
/// # What the lock may not be held across
///
/// Only the native arm or disarm call. Never a callback drain: a callback
/// blocked on this lock could then never finish, and the drain waiting for it
/// would never return.
pub ;