Skip to main content

Ticket

Struct Ticket 

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

Position in a sequence issued by Tickets.

The oldest outstanding ticket holds the turn. Passing or dropping it hands the turn to the next ticket; a ticket dropped before its turn is skipped.

Holding a ticket blocks the turn of every later ticket of the sequence, pass or drop it once its ordered side effect is done.

A canceled ticket keeps its position: its turn wait returns Canceled and dropping it passes or skips its turn as usual.

Implementations§

Source§

impl Ticket

Source

pub fn seq(&self) -> u64

Position in the sequence, starting from zero.

Source

pub fn is_turn(&self) -> bool

Returns true if this ticket holds the turn.

Source

pub fn is_canceled(&self) -> bool

Returns true if this ticket is canceled.

Returns false after pass().

Source

pub fn is_passed(&self) -> bool

Returns true if this ticket is passed.

Source

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

Polls until this ticket holds the turn.

Returns Err(Canceled) if the ticket is canceled, even if it holds the turn, or if it is passed.

Source

pub async fn turn(&self) -> Result<(), Canceled>

Waits until this ticket holds the turn.

Returns Err(Canceled) if the ticket is canceled, even if it holds the turn, or if it is passed.

Source

pub fn pass(&mut self)

Releases the turn of this ticket, same as drop, but keeps the ticket.

If the ticket holds the turn, the turn passes to the next outstanding ticket, otherwise its turn is skipped. The passed ticket can still cancel() the sequence. Passing again does nothing.

Source

pub fn cancel(&self)

Cancels every ticket of the sequence that is outstanding now.

Turn waits of canceled tickets return Canceled, tasks waiting for the turn are woken. A ticket that already got its turn keeps running. Tickets issued later are not canceled.

Trait Implementations§

Source§

impl Debug for Ticket

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Ticket

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Ticket

Source§

impl PartialEq for Ticket

Source§

fn eq(&self, other: &Ticket) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Turn for Ticket

Source§

fn poll_turn(&self, cx: &mut Context<'_>) -> Poll<Result<(), Canceled>>

Polls until this ticket holds the turn. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Ticket

§

impl !Send for Ticket

§

impl !Sync for Ticket

§

impl !UnwindSafe for Ticket

§

impl Freeze for Ticket

§

impl Unpin for Ticket

§

impl UnsafeUnpin for Ticket

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V