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
// Copyright (c) 2026 Mike Grier
//! Wake-only Model A delivery (M33.1, [D-84](../DESIGN-NOTES.md#d-84)): the ring's completion event
//! wired to a thread-pool wait that tells the ring's owner to drain, for a caller that keeps its
//! ring.
//!
//! [`EventDelivery`](crate::EventDelivery) is built on this, so the protocol below is written once.
use io;
use CallbackEnviron;
use ;
use crateIoRing;
/// Tells the owner of an [`IoRing`] to drain it, on a thread-pool thread, whenever the ring's
/// completion queue may have gone from empty to non-empty (Model A, D-3; D-84).
///
/// The counterpart to [`EventDelivery`](crate::EventDelivery) for a caller that keeps its ring --
/// behind its own lock, beside its own state -- and wants the thread pool only to say when to
/// drain. `EventDelivery` is this, with a drain that hands each completion to a callback, over a
/// ring it owns.
///
/// # What the owner owes
///
/// - **Drain to empty on every call.** The ring's event is an edge, raised when the completion
/// queue goes from empty to non-empty ([D-19](../DESIGN-NOTES.md#d-19)), so a call that leaves a
/// completion queued may never be followed by another.
/// - **Treat a call with nothing to pop as normal.** There is one at setup, and each activation
/// calls twice.
/// - **One waiter per ring** ([D-21](../DESIGN-NOTES.md#d-21)): no second wake over the same ring,
/// and no other wait on its event. Stated, not enforced, because the wake does not hold the ring.
/// - **Never drop the wake from inside its own call.** Dropping it waits for a running call, which
/// would be waiting for itself.
///
/// # What the owner may rely on
///
/// Both are contract, as they are for `EventDelivery` ([D-83](../DESIGN-NOTES.md#d-83)):
///
/// - **No lock and no ring is held while it calls.** The wake holds no reference to the ring, so
/// the owner may take its own lock in the call, pop, and push and submit more work.
/// - **Calls may overlap.** Two may run at once on different pool threads; the owner's own lock is
/// what serializes its ring.