Skip to main content

SubscriptionSlot

Enum SubscriptionSlot 

Source
pub enum SubscriptionSlot<D> {
    Idle,
    Reserved,
    Active(D),
}
Expand description

The one inner subscription an operator holds at a time.

D is the value being held — a Subscription in every current use, which disposes when dropped.

Variants§

§

Idle

Nothing is subscribed and nothing is being subscribed.

§

Reserved

A subscription is being built with the lock released. Reserving the slot up front is what tells a concurrent update that a subscription is on its way.

§

Active(D)

A subscription is held.

Implementations§

Source§

impl<D> SubscriptionSlot<D>

Source

pub fn is_idle(&self) -> bool

Whether the slot is Idle.

Source

pub fn is_reserved(&self) -> bool

Whether the slot is Reserved.

Source

pub fn reserve(&mut self) -> Option<D>

Reserves the slot for a subscription that is about to be built, and gives back the subscription it replaces, if any, to drop outside the lock.

§Panics

Panics if the slot is already reserved: only one build can be in flight, since the caller reserves under the same lock that serializes its updates.

Source

pub fn reserve_if_idle(&mut self) -> bool

Reserves the slot only if it is Idle, so nothing is ever evicted, and returns whether it did.

This is the form used by a host that keeps one task alive while there is work to do: it starts a task only when none is running, instead of replacing a running one.

Source

pub fn fill(&mut self, value: D) -> Option<D>

Fills a reserved slot with the subscription that was built.

Returns Some when the slot was released while the build was running — the operator terminated the inner subscription in the meantime — in which case the value was not stored and is given back to drop outside the lock.

§Panics

Panics if the slot is already active, which would mean a build was never reserved.

Source

pub fn release(&mut self) -> Option<D>

Releases the slot, giving back the held subscription, if any, to drop outside the lock.

Releasing a Reserved slot returns None and makes the pending fill give its subscription back instead of storing it.

Trait Implementations§

Source§

impl<D> Debug for SubscriptionSlot<D>
where D: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for SubscriptionSlot<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for SubscriptionSlot<D>
where D: RefUnwindSafe,

§

impl<D> Send for SubscriptionSlot<D>
where D: Send,

§

impl<D> Sync for SubscriptionSlot<D>
where D: Sync,

§

impl<D> Unpin for SubscriptionSlot<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for SubscriptionSlot<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for SubscriptionSlot<D>
where D: 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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

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.