Skip to main content

FillGroups

Struct FillGroups 

Source
pub struct FillGroups { /* private fields */ }
Expand description

A run of groups readers miss, for a Requests handler to serve.

It names start.group up to the exclusive end, the first group from start’s frame. A reader’s time start that no group the cache holds places asks for the group containing that time as a fill one key wide, from the time, whose first group may start below it: see floor. Its priority and order follow its readers as they change, so read them as each group is served. The handler calls accept for each group it has and drop_groups for the rest, one group at a time as poll_wanted_changed yields them, so it writes no faster than its readers read. Serve the fills you take concurrently: each waits on its own readers, so serving them in turn holds every fill behind the readers of the one before. Dropping the fill names whatever is left as dropped while a reader still wants it; once nobody does, the fill is withdrawn and records nothing, so stop serving it once wanted is None. A reader narrowing its ranges may leave a single group, so stop serving that one when poll_unwanted is ready and move on to wanted.

A clone serves the same fill, and the fill is settled once the last clone drops. Each clone watches on its own, so its first poll_wanted_changed reports the current value.

Implementations§

Source§

impl FillGroups

Source

pub fn start(&self) -> Position

The first group to fill, and the frame within it to start from.

Source

pub fn floor(&self) -> u64

The oldest group the first group may start at: start’s, unless that is a reader’s time start no group the cache holds places. Then the first group is the one containing that time: the group starting at it, or else the newest one starting before it, at or after the floor; once that group ends whole at or before the time, the reader starts past it, at its End. A handler knowing its groups only by key serves that key as any other; one that can tell which group holds the time, as from an index, may accept that group instead, or drop_groups the key when none does. The reader starts where the answer says, never where the groups the cache holds happen to say: a drop, or the fill closed unanswered, says no group starts from the floor through the time, so it starts at the group just below the floor (at its End once the time is past that group’s span), or past the time when the floor is 0. A refusal fails the reader with its error until its ranges change.

Source

pub fn is_time_start(&self) -> bool

Whether it answers a reader’s time start, whose first group is the one containing the time from the floor through it, even when the floor is the time itself: a drop then says no group starts there, and a refusal fails the reader.

Source

pub fn frame_start(&self, key: u64) -> u64

The frame group key starts from: start’s frame for the first group, 0 for the rest.

Source

pub fn end(&self) -> u64

The exclusive end group.

Source

pub fn priority(&self) -> i8

The most urgent delivery priority among the readers waiting on it now.

Source

pub fn order(&self) -> Order

Which end to fill first now: Order::Descending is newest first.

Source

pub fn accept( &self, key: u64, info: impl Into<Option<Info>>, ) -> Result<Option<Producer>>

Insert group key into the track’s cache, handing it to the readers waiting on it, and return a group::Producer to fill.

On a track this publisher accepted, a group past every one it produced is its live feed, which its subscriptions deliver too; one below is history, served only to whoever misses it. A relay’s copy leaves that to its upstream’s subscription.

The group starts at start’s frame when it is the first group, so the frames written keep the indices they have in the group. A key from the floor up to the start’s answers the start with that group, from its first frame. info sets the track’s Info if it hasn’t been accepted yet (a fetch with no live subscription), and is ignored otherwise. Returns None if the group was already answered or cached. Errors with Error::InvalidRange outside the fill, Error::Skipped if the track skipped it, or the track’s abort error.

A group is named by its frame 0’s timestamp, so on a timed track writing frame 0 at any other time is Error::TimestampMismatch.

Source

pub fn drop_groups(&self, groups: Range<u64>)

Name groups as never to be delivered: the source no longer has them. Readers stop waiting for them, and the track records them so nobody asks again. Only the groups a reader still reads count; the rest of the fill was never owed.

Source

pub fn refuse_groups(&self, groups: Range<u64>, err: Error)

Refuse groups with err without saying the source lost them, as when serving them failed for now or this request asks what the source can’t serve. The readers waiting now stop waiting, and a later reader asks again. Only the groups a reader still reads count, as with Self::drop_groups.

Source

pub fn is_wanted(&self, key: u64) -> bool

Whether a reader still waits for group key from this fill: false once every reader took it or narrowed past it, or nobody waits on the fill. A group stops being wanted for good; once accepted and taken, group::Producer::demand says who reads it.

Source

pub fn poll_unwanted(&self, key: u64, waiter: &Waiter) -> Poll<()>

Resolves once no reader waits for group key from this fill, so stop serving it.

Source

pub async fn unwanted(&self, key: u64)

Resolves once no reader waits for group key from this fill, so stop serving it.

Awaits poll_unwanted.

Source

pub fn wanted(&self) -> Option<u64>

The next group still owed in the fill’s order: a reader still reads it, and it was neither answered nor delivered live since it was asked. None once none is owed or no reader waits on the fill, so stop serving it. It does not wait for the readers to take what was served before it; poll_wanted_changed does.

Source

pub fn poll_wanted_changed(&mut self, waiter: &Waiter) -> Poll<Option<u64>>

The next group to serve: wanted once it differs from what this handle last returned and every group this fill answered reached a reader, which picks it up when it next reads. None once the fill is withdrawn, or answered and taken: keep the fill until then, since the cache holds what a reader has yet to take only while the fill lives. The first call returns at once, unless a group already answered has yet to reach a reader.

So while let Some(key) = fill.wanted_changed().await writes one group at a time as the fastest reader reads on. The cache holds the first group in the fill’s order that a reader has yet to take, which no eviction takes before it does: a fill holds at most one group, however far its readers fall behind, and a reader asks again for any other it loses. A reader reading in another order than the fill’s picks up groups it cannot take yet, so the fill moves on.

Source

pub async fn wanted_changed(&mut self) -> Option<u64>

The next group to serve: wanted once it differs from what this handle last returned and every group this fill answered reached a reader, which picks it up when it next reads. None once the fill is withdrawn, or answered and taken: keep the fill until then, since the cache holds what a reader has yet to take only while the fill lives. The first call returns at once, unless a group already answered has yet to reach a reader.

So while let Some(key) = fill.wanted_changed().await writes one group at a time as the fastest reader reads on. The cache holds the first group in the fill’s order that a reader has yet to take, which no eviction takes before it does: a fill holds at most one group, however far its readers fall behind, and a reader asks again for any other it loses. A reader reading in another order than the fill’s picks up groups it cannot take yet, so the fill moves on.

Awaits poll_wanted_changed.

Trait Implementations§

Source§

impl Clone for FillGroups

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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
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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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

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

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