Skip to main content

Completion

Struct Completion 

Source
pub struct Completion(/* private fields */);
Expand description

A lightweight in-process completion event.

Conceptually, a completion has an internal state of either unsignaled or signaled. Threads may wait on the completion until it achieves the signaled state, or alter its state.

On Fuchsia, this wraps sync_completion_t from zircon/system/ulib/sync.

Implementations§

Source§

impl Completion

Source

pub const fn new() -> Self

Creates a new completion in the unsignaled state.

Source

pub fn wait(&self)

Blocks the current thread until the completion is signaled.

Source

pub fn wait_for(&self, timeout: Duration) -> bool

Blocks the current thread until the completion is signaled or the timeout expires. Returns true if the completion was signaled, or false if it timed out.

Source

pub fn wait_until(&self, deadline: MonotonicInstant) -> bool

Blocks the current thread until the completion is signaled or the deadline is reached. Returns true if the completion was signaled, or false if it timed out.

Source

pub fn signal(&self)

Signals the completion, awakening all waiting threads.

Source

pub fn reset(&self)

Resets the completion to the unsignaled state.

Source

pub fn is_signaled(&self) -> bool

Returns true if the completion has been signaled.

Trait Implementations§

Source§

impl Default for Completion

Source§

fn default() -> Self

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

impl Send for Completion

Source§

impl Sync for Completion

Auto Trait Implementations§

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 = !

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.