pub struct ContextProbe {
last_asked: HashMap<SessionSlot, Instant>,
}Expand description
The socket’s bound on asking, held for the life of the fold.
Fields§
§last_asked: HashMap<SessionSlot, Instant>When the socket last asked for each seat’s reading.
Implementations§
Source§impl ContextProbe
impl ContextProbe
Sourcepub fn admit(
&mut self,
slot: &SessionSlot,
reading: impl FnOnce() -> ContextUsage,
now: Instant,
) -> Result<(), Declined>
pub fn admit( &mut self, slot: &SessionSlot, reading: impl FnOnce() -> ContextUsage, now: Instant, ) -> Result<(), Declined>
Whether the socket may ask for a fresh reading on slot, recording the
ask when it may.
The reading arrives as a thunk because it is built under the session’s lock, and the interval can refuse the ask without it - so a fold that took the reading first would hold that lock once per finished turn, on the one task that serves every client.
Sourcepub fn force(&mut self, slot: &SessionSlot, now: Instant)
pub fn force(&mut self, slot: &SessionSlot, now: Instant)
Record an ask made past both bounds, which is the one case they must not refuse: a compaction settled, so the held reading was taken from a transcript that no longer exists.
Both bounds read the reading they would be replacing, so without this a seat past the token gate refuses every ask and its number stands at the high value for the life of its occupant.
Sourcefn too_soon(&self, slot: &SessionSlot, now: Instant) -> bool
fn too_soon(&self, slot: &SessionSlot, now: Instant) -> bool
Whether slot was asked inside the interval, without building a
reading to find out.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextProbe
impl RefUnwindSafe for ContextProbe
impl Send for ContextProbe
impl Sync for ContextProbe
impl Unpin for ContextProbe
impl UnsafeUnpin for ContextProbe
impl UnwindSafe for ContextProbe
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
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