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>
impl<D> SubscriptionSlot<D>
Sourcepub fn is_reserved(&self) -> bool
pub fn is_reserved(&self) -> bool
Whether the slot is Reserved.
Sourcepub fn reserve(&mut self) -> Option<D>
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.
Sourcepub fn reserve_if_idle(&mut self) -> bool
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.
Sourcepub fn fill(&mut self, value: D) -> Option<D>
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.