Wait

Struct Wait 

Source
pub struct Wait<'wait_list, L: Lock, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>,
{ /* private fields */ }
Expand description

The future of a waiting operation.

This type provides a lower-level API than LockedExclusive::init_and_wait, but is useful if your guard types are !Send but you still want the outer future to remain Send.

Awaiting and polling this future will panic if you have not called init yet.

Implementations§

Source§

impl<'wait_list, L: Lock, I, O, OnCancel> Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>,

Source

pub fn new() -> Self

Create a new Wait future.

The returned future will be in its “completed” state, so attempting to .await it will panic unless init is called.

Source

pub fn is_completed(&self) -> bool

Check whether this future is in its completed state or not.

Source

pub fn init( self: Pin<&mut Self>, waker: Waker, guard: &mut LockedExclusive<'wait_list, L, I, O>, input: I, on_cancel: OnCancel, )

Initialize the future, moving it from a completed to waiting state.

This function is mostly only useful inside a poll function (when you have a cx variable to hand). After calling this, you should return Poll::Pending as the given waker has been successfully registered in the wait list.

A callback must be supplied to call in the event that the future has been woken but was cancelled before it could complete. You will often want to re-call LockedExclusive::wake_one in this case to pass on the notification to someone else.

§Panics

Panics if called on a non-completed future.

Source

pub fn init_without_waker( self: Pin<&mut Self>, guard: &mut LockedExclusive<'wait_list, L, I, O>, input: I, on_cancel: OnCancel, )

The same as init but not requiring a task::Waker, instead substituting in a temporary no-op waker.

Using this API is always less efficient than writing a poll function manually that calls init, but it can be useful if you (a) need Send futures but have !Send mutex guards and (b) want to stay in an async context.

Source

pub fn wait_list(&self) -> &'wait_list WaitList<L, I, O>

Retrieve a shared reference to the WaitList this Wait is currently associated with.

§Panics

Panics if the wait is currently in the “completed” state.

Trait Implementations§

Source§

impl<'wait_list, L, I: Debug, O, OnCancel> Debug for Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>, L: Debug + Lock, <L as Lifetime<'wait_list>>::ExclusiveGuard: Debug,

Source§

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

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

impl<'wait_list, L: Lock, I, O, OnCancel> Default for Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'wait_list, L: Lock, I, O, OnCancel> Drop for Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'wait_list, L: Lock, I, O, OnCancel> Future for Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: CancelCallback<'wait_list, L, I, O>,

Source§

type Output = (LockedExclusive<'wait_list, L, I, O>, O)

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

§

impl<'wait_list, L, I, O, OnCancel> !Freeze for Wait<'wait_list, L, I, O, OnCancel>

§

impl<'wait_list, L, I, O, OnCancel> !RefUnwindSafe for Wait<'wait_list, L, I, O, OnCancel>

§

impl<'wait_list, L, I, O, OnCancel> Send for Wait<'wait_list, L, I, O, OnCancel>
where OnCancel: Send, L: Sync, I: Send + Sync, O: Send,

§

impl<'wait_list, L, I, O, OnCancel> Sync for Wait<'wait_list, L, I, O, OnCancel>
where O: Sync + Send, L: Sync, I: Send + Sync,

§

impl<'wait_list, L, I, O, OnCancel> !Unpin for Wait<'wait_list, L, I, O, OnCancel>

§

impl<'wait_list, L, I, O, OnCancel> !UnwindSafe for Wait<'wait_list, L, I, O, OnCancel>

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
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.