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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//! Observability for the awaited push path's capacity waits.
//!
//! The push API already answers "was the queue full?" for the *non-blocking*
//! path: a `try_push` that finds no room returns `QueueFull`, and the policies
//! built on it drop or dead-letter the frame. The awaited path has no
//! equivalent answer. An awaited `push_high_priority` against a full queue
//! returns nothing at all — it parks until a consumer frees a slot — so a
//! workload that spent its whole run blocked on back-pressure is
//! indistinguishable, from the outside, from one that never queued.
//!
//! That gap matters for any claim of the form "this scenario saw no
//! back-pressure". A start barrier and a draining consumer make waiting
//! *possible* or *unlikely*; neither makes it *absent*, and neither leaves
//! evidence either way. [`PushWaitCounts`] is the recorder that closes the gap.
//! It lives in the handle and is incremented by
//! [`PushHandle::push_with_priority`](super::PushHandle); the public read
//! surface is [`PushHandle::wait_counters`](super::PushHandle), which returns a
//! [`PushWaitCounters`] snapshot.
use ;
/// Counters describing what one producer's awaited pushes had to wait for.
///
/// A plain struct of integers rather than a live handle, so a caller can
/// snapshot it, store it, and subtract one snapshot from another without
/// holding the handle alive.
///
/// # Why this is not `reported_queue_full`
///
/// A non-blocking send that fails asks a different question from a blocking one
/// that parks, and the push API's existing `QueueFull` report answers only the
/// first. A `try_push` against a full queue returns `QueueFull` whether or not
/// anyone subsequently waits; an awaited `push_high_priority` against a full
/// queue returns nothing at all and simply parks. The two are not
/// interchangeable: a workload can be full of awaited back-pressure and report
/// `reported_queue_full: false` for every send, because that flag is set only
/// by the non-blocking path.
///
/// So this counts the awaited path directly. `awaited_capacity_waits` moves
/// exactly when an awaited push found no free slot and had to park, which is
/// the condition a "no back-pressure" claim needs to rule out and a
/// "back-pressure" scenario needs to establish.
/// The live recorder behind [`PushWaitCounters`].
///
/// Separate from the snapshot because a handle outlives any one reading: the
/// atomics are shared by every clone of a [`PushHandle`](super::PushHandle),
/// and callers take snapshots rather than resetting shared state, so a reading
/// cannot be lost or double-counted by another producer.
///
/// The atomics are `std`'s rather than loom-aliased. These are diagnostics for
/// a benchmark, not a shared invariant any model checks, and the loom models
/// that exercise the push path assert on drop counts instead. Keeping them out
/// of loom's registry also keeps every push in a model from adding two atomic
/// accesses to the state space.
pub
/// Count one capacity wait the first time a send poll reports `Pending`.
///
/// Split out of the `poll_fn` closure so the closure stays a poll and a call,
/// keeping it under the repository's nesting ceiling.
pub