Skip to main content

Table

Struct Table 

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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_wake the same task as waker, which is a refresh: the stored waker is replaced and not woken (ADR-0021 decision 13);
  • waker itself, not stored, when no outcome is still to be recorded under c: the outcome is already known, the call was forgotten, or the table holds no call under c. A stored waker would never be woken, and the task’s read that follows finds what there is.
Source

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.

Trait Implementations§

Source§

impl<const N: usize> Debug for Table<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Table<N>
where [Entry; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for Table<N>
where [Entry; N]: RefUnwindSafe,

§

impl<const N: usize> Send for Table<N>
where [Entry; N]: Send,

§

impl<const N: usize> Sync for Table<N>
where [Entry; N]: Sync,

§

impl<const N: usize> Unpin for Table<N>
where [Entry; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for Table<N>
where [Entry; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for Table<N>
where [Entry; N]: UnwindSafe,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.