Skip to main content

Streams

Struct Streams 

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

The fleet’s stream table. Cheap to clone; every clone in a process is the same table, the same driver and the same wakers.

Implementations§

Source§

impl Streams

Source

pub fn new(fleet: Arc<Fleet>, incarnation: Incarnation) -> Result<Self>

Open the fleet’s table as this process’s incarnation. Every side this process claims is stamped with it, and Streams::node_dead for the same node and incarnation is what ends those sides.

Source

pub fn with_spec( fleet: Arc<Fleet>, incarnation: Incarnation, spec: StreamSpec, ) -> Result<Self>

Open the table spec names. Independent specs are independent tables: separate segments, separate lanes and rings, separate epochs, and a reset_all on one leaves the others alone. A process may hold as many as it has specs, but each under one incarnation.

Source

pub fn kind(&self) -> u8

The kind this table’s segment lives under.

Source

pub fn readiness(&self) -> Result<Readiness>

A descriptor that becomes readable when something among this process’s streams may have changed, for a runtime that parks on descriptors rather than on wakers.

Edge-triggered and coalescing: drain it, then re-try the non-blocking calls on the streams you hold. It is what makes this table usable from a foreign event loop — an embedded runtime, a reactor of its own — without a thread or a descriptor per stream.

One per table: a second caller is refused rather than handed a descriptor whose signals the first would drain.

Source

pub fn epoch(&self) -> u64

The epoch every ticket minted from this table carries right now.

Source

pub fn create(&self) -> Result<(Endpoint, Ticket)>

Take a slot in this process’s lane. The endpoint is side A; the ticket names side B and is what the other end opens.

Source

pub fn open(&self, ticket: Ticket) -> Result<Endpoint>

Hold the side a ticket names. Each side can be held once per stream.

Source

pub fn is_live(&self, id: StreamId) -> bool

Whether the address names a live stream right now.

Source

pub fn offer(&self, ticket: Ticket, to: NodeId) -> Result<()>

Tell node’s process that side B of this stream is its to take: the slot is put in that node’s offer bitmap and its doorbell rung. Discovery only; the ticket may just as well travel by any other channel. An offer is seen once, by that node, through Streams::take_offer and its waiting forms.

Source

pub fn take_offer(&self) -> Option<Ticket>

The next stream offered to this node, if any. A stream that ended between the offer and now is skipped.

Source

pub fn take_offer_timeout(&self, timeout: Duration) -> Result<Option<Ticket>>

The same wait, bounded: None is the timeout and nothing else. A worker whose shutdown must be observed waits this way rather than parking on the next request forever.

Source

pub fn blocking_take_offer(&self) -> Result<Ticket>

Park the thread until a stream is offered to this node.

Source

pub fn poll_take_offer(&self, cx: &mut Context<'_>) -> Poll<Result<Ticket>>

Readiness for a task: the next offer, or the waker is registered and Pending comes back.

Source

pub fn owners(&self) -> Vec<(NodeId, Incarnation)>

Every process generation that still holds a side of a stream here.

The mirror of Pool::owners, and for the same caller: a supervisor that has to decide what to report dead after losing its own record. It says who is in the table, never who is alive.

Source

pub fn node_dead(&self, node: NodeId, incarnation: Incarnation)

A confirmed death, reported by whoever supervises processes: every side that incarnation of node held, in any lane, is finished. Its unfinished writes become resets and its reads are gone, so a holder of the other side wakes with an error; that holder keeps the slot until it drops its handles, and only then is the slot reused. A report for another incarnation of the same node touches nothing.

Source

pub fn reset_all(&self)

Clear the table during quiescent owner boot and start a new epoch. Every handle and every ticket from before goes stale.

Remove the SHM object. Existing mappings stay valid until their processes release them.

Trait Implementations§

Source§

impl Clone for Streams

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