Struct pawawwewism::Promise
source · pub struct Promise<T> { /* private fields */ }
Expand description
An empty slot that can be filled with a T
, fulfilling the promise.
Fulfilling a Promise
lets the connected PromiseHandle
retrieve the value. A connected
pair of Promise
and PromiseHandle
can be created by calling promise
.
Implementations§
source§impl<T> Promise<T>
impl<T> Promise<T>
sourcepub fn fulfill(self, value: T)
pub fn fulfill(self, value: T)
Fulfills the promise with a value, consuming it.
If a thread is currently waiting at PromiseHandle::block
, it will be woken up.
This method does not block or fail. If the connected PromiseHandle
was dropped, value
will be dropped and nothing happens. The calling thread is expected to exit when it attempts
to obtain a new Promise
to fulfill.
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for Promise<T>
impl<T> Send for Promise<T>where T: Send,
impl<T> Sync for Promise<T>where T: Send,
impl<T> Unpin for Promise<T>
impl<T> UnwindSafe for Promise<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more