pub struct Table<const N: usize> { /* private fields */ }Expand description
The caller-side call table: N slots, each with a generation, the call’s
outcome status, and one waker, and an optional byte budget.
Every method takes &self or &mut self and returns; a runtime keeps the
table behind its own lock. See the module documentation.
Implementations§
Source§impl<const N: usize> Table<N>
impl<const N: usize> Table<N>
Sourcepub const fn new(budget: Option<u64>) -> Self
pub const fn new(budget: Option<u64>) -> Self
An empty table. budget is the byte budget reservations are debited
from — a runtime with a catalog descriptor sizes it with
table_budget — or None for no
budget, in which case only the slot count bounds the calls in flight.
Sourcepub fn insert(&mut self, reservation: u64) -> Option<Correlation>
pub fn insert(&mut self, reservation: u64) -> Option<Correlation>
Takes the lowest free slot for a new call and debits reservation
from the budget. None when every slot is in flight or settled and
unforgotten, or when the budget has fewer than reservation bytes
free; a runtime answers either with SendError::Busy. Without a
budget, reservation is not read.
Sourcepub fn settle(
&mut self,
c: Correlation,
outcome: Result<(), CallError>,
) -> Settled
pub fn settle( &mut self, c: Correlation, outcome: Result<(), CallError>, ) -> Settled
Records the outcome of the call in flight under c, or, when the call
was forgotten, reclaims its slot. The first settlement of a call is
its outcome; a later one is Settled::Unknown and changes nothing.
Sourcepub fn outcome(&self, c: Correlation) -> Option<Result<(), CallError>>
pub fn outcome(&self, c: Correlation) -> Option<Result<(), CallError>>
The outcome recorded for c, or None while it is in flight, after it
is forgotten, or when the table holds no call under c. Reading it
does not reclaim the slot: only forget does.
Sourcepub fn forget(&mut self, c: Correlation) -> Forgotten
pub fn forget(&mut self, c: Correlation) -> Forgotten
Releases c, the one operation that reclaims a slot: at once for a
settled call, and at its settlement for a call in flight, which this
marks. Either way c has no readable outcome afterwards.
Sourcepub fn wake_on(&mut self, c: Correlation, waker: &Waker) -> Option<Waker>
pub fn wake_on(&mut self, c: Correlation, waker: &Waker) -> Option<Waker>
Stores waker as the Interest::Outcome(c) waker of the call in
flight under c, and returns the waker to wake:
- the displaced waker, when the call held a waker of another task;
- nothing, when the stored waker
will_wakethe same task aswaker, which is a refresh: the stored waker is replaced and not woken (ADR-0021 decision 13); wakeritself, not stored, when no outcome is still to be recorded underc: the outcome is already known, the call was forgotten, or the table holds no call underc. A stored waker would never be woken, and the task’s read that follows finds what there is.
Sourcepub fn slot(c: Correlation) -> usize
pub fn slot(c: Correlation) -> usize
The slot index of c, which a runtime uses to index its own storage
for the call — reply bytes, arguments — beside the table.