Skip to main content

Shared

Struct Shared 

Source
struct Shared {
    subscribers: Vec<Registration>,
    sequences: HashMap<SessionSlot, u64>,
    rings: HashMap<SessionSlot, VecDeque<Kept>>,
    ring_bytes: HashMap<SessionSlot, usize>,
    unringed: HashMap<SessionSlot, VecDeque<u64>>,
    sealed_with_rows: HashSet<SessionSlot>,
    ring_cap: usize,
    ring_cap_bytes: usize,
}

Fields§

§subscribers: Vec<Registration>§sequences: HashMap<SessionSlot, u64>

Where each seat’s stream has got to: the number its newest frame was minted under. Absent for a seat that has not emitted yet, and for one whose last frame opened a new epoch.

Per seat, keyed by the frame’s own slot, so a frame for one seat can neither advance another’s counter nor leave a hole in it.

§rings: HashMap<SessionSlot, VecDeque<Kept>>

The newest frames each seat’s stream has emitted, oldest first, for a client that read a gap in the numbers and asks for what it missed.

Held here rather than on the session task because here is where every frame of the seat crosses, whichever site emitted it - and the number a repair hands back is the one minted here.

§ring_bytes: HashMap<SessionSlot, usize>

What each seat’s ring weighs, beside the frames themselves, so the byte ceiling is a running total rather than a walk of the ring.

§unringed: HashMap<SessionSlot, VecDeque<u64>>

The numbers each seat has minted that the ring does NOT hold: the frames that close an epoch. A reader measuring whether a copy covers a stretch needs them, because a window can never serve them and a gap holding only one of them costs the copy nothing.

Per epoch, not per seat. An occupant change mints from 1 again, so the numbers a seal’s epoch carried are re-minted by the run after it - and the record of them goes with the ring. Bounded to a ring’s frame count: a number older than that lies beyond any window a fill could serve, where the count it underwrites is a refusal rather than a hole.

§sealed_with_rows: HashSet<SessionSlot>

The seats whose latest epoch-opening seal carried rows.

A seal’s history is not in the ring, so a reader filling a copy from the window cannot rebuild what the epoch opened on (#2446). An empty-history seal opens its epoch with nothing to miss, so each mint REPLACES this rather than adding to it. The value standing between an occupant change and its seal’s mint is the previous seal’s, which is what notices that gap.

§ring_cap: usize

How many frames a ring keeps. SEAT_RING in production; a test drives it down so the transcript fallback is reachable without emitting thousands of frames.

§ring_cap_bytes: usize

How many bytes a ring keeps. SEAT_RING_BYTES in production; a test drives it down so the ceiling is reachable without a giant tree.

Implementations§

Source§

impl Shared

Source

fn numbered(&mut self, update: SessionUpdate, charge: usize) -> SeatUpdate

Number update on its seat’s counter, or leave it unnumbered when it belongs to no seat.

An occupant change closes its epoch. Connected and SessionReplaced are numbered on the run they end and the seat’s counter starts over, so the frame after one opens the new epoch at 1: the client learns the occupant from that frame itself and wipes to expect 1, never a gap.

One lock serializes numbering and delivery. UpdateFanout::deliver mints and fans out under the same guard, so the numbers a seat’s subscribers receive are in the order they were minted. Lifting the mint out of that guard - or fanning out around it - reorders a seat’s stream against its own numbers.

Source

fn frames_between( &self, slot: &SessionSlot, from: u64, to: u64, ) -> Vec<SeatUpdate>

The frames of slot’s ring that carry the numbers in from..=to, oldest first.

Source

fn oldest_kept(&self, slot: &SessionSlot) -> Option<u64>

The oldest number slot’s ring still holds, None for a seat that has emitted nothing.

Source

fn unringed_between(&self, slot: &SessionSlot, from: u64, to: u64) -> u64

How many of the numbers in from..=to on slot’s stream the ring holds no frame for.

Source

fn next_seq(&self, slot: &SessionSlot) -> u64

The number slot’s next frame will be minted under.

A seat that has emitted nothing - and one whose last frame opened a new epoch - is at 1, so this never answers 0: a client reads it as the number to expect, and 0 would have it expect a frame that cannot exist.

Source

fn epoch_opened_with_rows(&self, slot: &SessionSlot) -> bool

Whether slot’s latest epoch-opening seal carried rows.

Trait Implementations§

Source§

impl Default for Shared

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more