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
//! WHERE a node's input comes from: the seam the resident parks on, and the select a node with
//! SEVERAL upstreams waits in.
//!
//! # One upstream is an inbox; several are channels and a select
//!
//! A node that draws from ONE upstream has one bounded edge and parks on it — that is
//! [`Inbox`](super::Inbox), and it is what every node in this crate carried until now. A node whose
//! declaration writes a `subscribe(…)` container draws from SEVERAL, and giving those one inbox
//! would couple them: the edge's capacity is shared, so a slow producer filling it stops a fast one
//! from sending at all. So each upstream gets its own edge with its own capacity, and the consumer
//! waits on all of them at once. That is the ruled shape — per-upstream channels and a select — and
//! this module is the runtime half of it.
//!
//! # The seam, and why it is a TYPE PARAMETER rather than an enum
//!
//! [`Intake`] is the dual of [`Sink`](super::Sink) and it is spent the same way: a
//! [`Resident`](super::Resident) carries its intake as a parameter defaulted to the framework's
//! one-upstream shape, so a node with one upstream names nothing and pays nothing, and a node with
//! several hands its own. The intake a `subscribe(…)` container needs is per-node — one field per
//! upstream, each a different message type — which is a struct only that node's own expansion can
//! write; the framework supplies what such a struct is BUILT from: this trait, the [`select`] it
//! parks in, the [`arm`] each upstream contributes, and the [`Pairing`](super::Pairing) that joins the
//! keyed group.
//!
//! # Both engines, one select
//!
//! The async engine awaits [`Intake::park_async`] directly. The thread engine drives that same
//! future on its own thread with [`park_on`], which is [`block_on`](super::lane::block_on) with the
//! sweep as a deadline — so the two engines differ in the same one call they already differed in,
//! and there is one select rather than one per engine.
//!
//! # The select device lives one layer down
//!
//! [`select`], [`Arm`] and [`park_on`] are [`conduit`](crate::conduit)'s, and are re-exported here
//! because this is where the framework spends them. They were promoted when a node's own body
//! became a party that selects: such a body mixes framework edges with channels it opened itself,
//! and a device that only the framework could name would have left it selecting over one of the two.
//! What stays here is what is INBOX-shaped: the seam, its one-source impl, and [`arm`].
use ;
pub use crate;
use ;
/// WHERE a node's input comes from — the capability its intake implements.
///
/// Three calls, and they are the three the resident's loop makes: park (each engine's own), and
/// drain, which is what lets one wake serve a whole burst.
///
/// # The futures promise no `Send`
///
/// [`park_async`](Self::park_async) is bounded exactly as
/// [`AsyncOperator::accept`](crate::AsyncOperator::accept) is, and for the same reason: `Send`
/// belongs to the ENGINES. A body that holds a `!Send` intake across an await is an ordinary citizen on the thread
/// engine and is `E0277` at the async door, which is where the question is asked — see
/// [`Ignition::spawn`](crate::Ignition::spawn). [`Sink::deliver`](super::Sink::deliver) does promise
/// it, and the asymmetry is deliberate: a dispatch is awaited from inside a spawned body, while a
/// park is the loop's own wait.
/// The ONE-SOURCE intake: a node's own inbox, however many producers send into it.
///
/// The shape every node in this crate carries unless its declaration says otherwise, and the
/// [`Resident`](super::Resident)'s default — so this impl is what makes the seam free for the
/// single-upstream world. Fan-in by [`Outbox`](super::Outbox) clones is unchanged and is a different
/// thing from a keyed group: several producers of ONE message type meeting on one edge, rather than
/// several message types joined into a sum.
/// ONE arm of a [`select`]: park on `inbox` unless it has already hung up, wrapping what arrives.
///
/// `None` is that upstream's own shutdown — the caller marks the arm closed and selects over what is
/// left. An arm that is already closed NEVER answers, which is what keeps a hung-up upstream from
/// spinning the select: `recv` on a disconnected channel returns immediately, so re-offering one
/// would be a busy loop rather than a wait.
///
/// `wrap` is what tells the arms apart. Each upstream carries a different message type and a select
/// answers ONE, so the arms meet at whatever the intake's own classification wants — usually its
/// per-upstream enum.
///
/// [`conduit::arm`](crate::conduit::arm) is this one at the general transport — same shape, one
/// vocabulary over — and a node's own body selecting over both spends the two side by side.
pub async