pub(crate) struct UpdateFanout {
shared: Arc<Mutex<Shared>>,
}Expand description
Cloneable sender half of the workspace’s fan-out to its subscribers.
Every clone shares one registry. Self::send hands the update to
each subscriber and drops any whose receiver has gone, so the
registry never keeps a dead one.
Fields§
Implementations§
Source§impl UpdateFanout
impl UpdateFanout
Sourcepub(crate) fn subscribe(
&self,
role: SubscriberRole,
) -> UnboundedReceiver<SeatUpdate>
pub(crate) fn subscribe( &self, role: SubscriberRole, ) -> UnboundedReceiver<SeatUpdate>
Mint a subscriber stream, declaring what the caller can do with it. A stream carries what is emitted after this call and nothing before it; a subscriber reads what it missed from the subject’s snapshot instead.
Sourcepub(crate) fn send(&self, update: SessionUpdate) -> bool
pub(crate) fn send(&self, update: SessionUpdate) -> bool
Deliver update to every subscriber, and report whether one took
it. false is the “no receiver” signal the single-take channel
gave, which spawn::try_emit and SessionTask::emit log on.
One update, one pointer. The frame is wrapped once and each
subscriber is handed an Arc clone, so the fan-out never pays a
payload copy however many subscribers there are. The last subscriber
is taken out of the registry to receive it directly and goes back only
if it took it, which is also where a dead one leaves.
Sourcepub(crate) fn next_seq(&self, slot: &SessionSlot) -> u64
pub(crate) fn next_seq(&self, slot: &SessionSlot) -> u64
The number slot’s next frame will be minted under.
The read behind a seat’s reconnect answer: the occupant names the epoch and this names where its stream stands, so a client that has just read the seat knows exactly what to expect next.
Sourcepub(crate) fn frames_between(
&self,
slot: &SessionSlot,
from: u64,
to: u64,
) -> Vec<SeatUpdate>
pub(crate) fn frames_between( &self, slot: &SessionSlot, from: u64, to: u64, ) -> Vec<SeatUpdate>
The frames of slot’s window numbered in from..=to, oldest first,
for a client that read a gap in them.
Sourcepub(crate) fn oldest_kept(&self, slot: &SessionSlot) -> Option<u64>
pub(crate) fn oldest_kept(&self, slot: &SessionSlot) -> Option<u64>
The oldest number slot’s window still holds: what tells a range it
can answer from memory from one it cannot.
Sourcepub(crate) fn unringed_between(
&self,
slot: &SessionSlot,
from: u64,
to: u64,
) -> u64
pub(crate) fn unringed_between( &self, slot: &SessionSlot, from: u64, to: u64, ) -> u64
How many numbers in from..=to on slot’s stream no window can hold.
Sourcepub(crate) fn epoch_opened_with_rows(&self, slot: &SessionSlot) -> bool
pub(crate) fn epoch_opened_with_rows(&self, slot: &SessionSlot) -> bool
Whether slot’s latest epoch-opening seal carried rows, which no ring
holds.
Sourcepub(crate) fn set_ring_cap(&self, cap: usize)
pub(crate) fn set_ring_cap(&self, cap: usize)
Drive the ring’s cap down, so a test reaches the transcript fallback without emitting a window’s worth of frames.
Sourcepub(crate) fn count(&self) -> usize
pub(crate) fn count(&self) -> usize
How many subscribers are attached.
A test uses this to tell one subscription from another. “Did anyone receive” cannot: a listener that is always there - the socket’s own fold - makes every emit land, however many views have come and gone.
Sourcepub(crate) fn answering_count(&self) -> usize
pub(crate) fn answering_count(&self) -> usize
How many subscribers could answer a prompt. Test-only: the role decides whether the core parks a turn on a subscriber’s reply, and nothing else reports it.
Sourcepub(crate) fn send_answering(&self, update: SessionUpdate) -> bool
pub(crate) fn send_answering(&self, update: SessionUpdate) -> bool
Deliver update to every subscriber, and report whether one that
can ANSWER it took it. A path that parks a turn on an answer uses
this rather than Self::send: an observer takes the update and
never replies, so counting it would leave the turn waiting on a
response nobody will send.
An update emitted before anything attached reaches nobody: a
subscriber takes what follows its own subscribe. So a caller must
fail its turn closed on a false return; one that parked the
turn anyway belongs on Self::send.
fn deliver( &self, update: SessionUpdate, required: Option<SubscriberRole>, ) -> bool
Trait Implementations§
Source§impl Clone for UpdateFanout
impl Clone for UpdateFanout
Auto Trait Implementations§
impl !RefUnwindSafe for UpdateFanout
impl !UnwindSafe for UpdateFanout
impl Freeze for UpdateFanout
impl Send for UpdateFanout
impl Sync for UpdateFanout
impl Unpin for UpdateFanout
impl UnsafeUnpin for UpdateFanout
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more