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
impl Streams
Sourcepub fn new(fleet: Arc<Fleet>, incarnation: Incarnation) -> Result<Self>
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.
Sourcepub fn with_spec(
fleet: Arc<Fleet>,
incarnation: Incarnation,
spec: StreamSpec,
) -> Result<Self>
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.
Sourcepub fn readiness(&self) -> Result<Readiness>
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.
Sourcepub fn create(&self) -> Result<(Endpoint, Ticket)>
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.
Sourcepub fn open(&self, ticket: Ticket) -> Result<Endpoint>
pub fn open(&self, ticket: Ticket) -> Result<Endpoint>
Hold the side a ticket names. Each side can be held once per stream.
Sourcepub fn offer(&self, ticket: Ticket, to: NodeId) -> Result<()>
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.
Sourcepub fn take_offer(&self) -> Option<Ticket>
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.
Sourcepub fn take_offer_timeout(&self, timeout: Duration) -> Result<Option<Ticket>>
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.
Sourcepub fn blocking_take_offer(&self) -> Result<Ticket>
pub fn blocking_take_offer(&self) -> Result<Ticket>
Park the thread until a stream is offered to this node.
Sourcepub fn poll_take_offer(&self, cx: &mut Context<'_>) -> Poll<Result<Ticket>>
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.
Sourcepub fn owners(&self) -> Vec<(NodeId, Incarnation)>
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.
Sourcepub fn node_dead(&self, node: NodeId, incarnation: Incarnation)
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.