Struct Ready

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

A synchronization primitive that can be used to block a thread until a value is ready. The procedure is as follows:

  1. The Caller calls step(NOT_READY) to indicate that it is about to start the initialization process.
  2. The Caller initializes the value.
  3. The Caller calls step(IN_TRANSIT) to indicate that the value is ready. If step 1 fails, the value is already being initialized and the Caller must wait until is() returns true.

Implementations§

Source§

impl Ready

Source

pub const fn new() -> Self

Initializes a new Ready.

Source

pub fn step(&self, from: u8) -> bool

Move the Ready to the next state, if it is in state from.

Source

pub fn is(&self) -> bool

Returns true if the value is ready.

Auto Trait Implementations§

§

impl !Freeze for Ready

§

impl RefUnwindSafe for Ready

§

impl Send for Ready

§

impl Sync for Ready

§

impl Unpin for Ready

§

impl UnwindSafe for Ready

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> ThreadArgument for T
where T: Send + 'static,