pub trait Wake { fn wake(self: Arc<Self>); fn wake_by_ref(self: &Arc<Self>) { ... } }
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.
fn wake(self: Arc<Self>)
Wake this task.
fn wake_by_ref(self: &Arc<Self>)
Wake this task without consuming the waker.
If an executor supports a cheaper way to wake without consuming the waker, it should override this method. By default, it clones the Arc
and calls wake
on the clone.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/task/trait.Wake.html