pub struct MergedEvents<T> { /* private fields */ }Expand description
The host’s end of a fan-in: every tagged sink’s events, in arrival order.
§When the stream ends
recv returns None once every sink minted from the fan-in
has been dropped, and not before.
The sharp edge is that a run gives its sink back: a finished run yields a
RunReport with the sink in it, so a report held is a
branch of the stream held open, even though that run has nothing left to
say. A host that awaits its runs and its consumer in one
tokio::join! must let the reports go inside the branch that produced
them — take the final message, the outcome, whatever it wanted — or the
join will wait on a stream that is waiting on the join.
The other shape has no edge at all: fan out, join the runs, and then
drain what arrived. Nothing was lost while nobody was
reading, because the queue is unbounded.
Implementations§
Source§impl<T> MergedEvents<T>
impl<T> MergedEvents<T>
Sourcepub async fn recv(&mut self) -> Option<TaggedEvent<T>>
pub async fn recv(&mut self) -> Option<TaggedEvent<T>>
The next event from any run, or None once every sink is gone.
Cancel-safe, so this composes with tokio::select! as well as with a
plain while let loop.
Sourcepub fn blocking_recv(&mut self) -> Option<TaggedEvent<T>>
pub fn blocking_recv(&mut self) -> Option<TaggedEvent<T>>
Sourcepub fn drain(&mut self) -> Vec<TaggedEvent<T>>
pub fn drain(&mut self) -> Vec<TaggedEvent<T>>
Everything that has already arrived, without waiting for more.
What a host reads after joining its runs, and what a UI that repaints on
its own schedule reads each frame. An empty result means nothing has
arrived yet — it does not mean the stream is over, which only
recv can say.