Trait Wake
trait Wake
The implementation of waking a task on an executor.
This trait can be used to create a Waker. An executor can define an
implementation of this trait, and use that to construct a Waker to pass
to the tasks that are executed on that executor.
This trait is a memory-safe and ergonomic alternative to constructing a
RawWaker. It supports the common executor design in which the data used
to wake up a task is stored in an Arc. Some executors (especially
those for embedded systems) cannot use this API, which is why RawWaker
exists as an alternative for those systems.
To construct a Waker from some type W implementing this trait,
wrap it in an Arc<W> and call Waker::from() on that.
It is also possible to convert to RawWaker in the same way.
Examples
A basic block_on function that takes a future and runs it to completion on
the current thread.
Note: This example trades correctness for simplicity. In order to prevent
deadlocks, production-grade implementations will also need to handle
intermediate calls to thread::unpark as well as nested invocations.
use Future;
use Arc;
use ;
use ;
use pin;
/// A waker that wakes up the current thread when called.
;
/// Run a future to completion on the current thread.
block_on;
Required Methods
fn wake(self: Arc<Self>)Wake this task.