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
//! SPMC bench traits and bench cores.
//!
//! The trait is const-generic over `CAPACITY` so it matches how our own SPMC
//! exposes capacity (compile-time). Adapters over crates whose capacity is
//! runtime forward `CAPACITY` to their runtime constructor.
//!
//! Two semantic families exist behind this trait:
//!
//! - Overwriting broadcast (ours, nexus-queue): `try_publish` always returns
//! `Ok(())`; slow consumers observe `SpmcReadResult::Lapped { skipped }` on
//! their next `try_read`.
//! - Backpressure broadcast (bus): `try_publish` returns `Err(v)` when the
//! slowest consumer is behind; no data loss, but the publisher can be
//! throttled by the slowest reader.
//!
//! The two families use the same trait signatures. Bench cores that only
//! make sense against one family gate on [`SpmcSemantics`] via
//! [`SpmcBench::SEMANTICS`] and skip the others with a diagnostic.
use fmt;
pub use ;
pub use ;
pub use ;
/// Outcome of a single `try_read` call on an SPMC consumer.
///
/// Backpressure impls never return `Lapped` (no data loss by construction);
/// overwriting impls return it when the producer has lapped this consumer's
/// read cursor since the last read.
/// Producer half of an SPMC broadcast, as seen by the bench harness.
///
/// `try_publish` returns `Ok(())` on success. For overwriting impls the
/// method always succeeds (the queue overwrites its oldest slot). For
/// backpressure impls the method returns `Err(v)` when the slowest consumer
/// is behind; the bench loops the spin externally so the wait cost is
/// visible in the recorded percentile. The unified return type keeps bench
/// cores impl-agnostic.
/// Consumer half of an SPMC broadcast, as seen by the bench harness.
/// Which of the two SPMC semantic families a given impl belongs to.
///
/// Bench cores that only make sense against one family gate on this const
/// and skip incompatible impls with a diagnostic. See the module docs for
/// the family definitions.
/// Tag type that constructs an SPMC producer plus `n_consumers` consumer
/// handles, all with the same underlying queue of capacity `CAPACITY`.
///
/// Implementors are zero-sized markers that route generic instantiations
/// through [`new`](Self::new). The constructor takes `n_consumers` because
/// impls differ in how consumers are minted (clone vs `add_rx` on the
/// publisher); hiding that behind the trait keeps bench cores uniform.