Trait LocalWake
trait LocalWake
An analogous trait to Wake but used to construct a LocalWaker.
This API works in exactly the same way as Wake,
except that it uses an Rc instead of an Arc,
and the result is a LocalWaker instead of a Waker.
The benefits of using LocalWaker over Waker are that it allows the local waker
to hold data that does not implement Send and Sync. Additionally, it saves calls
to Arc::clone, which requires atomic synchronization.
Examples
This is a simplified example of a spawn and a block_on function. The spawn function
is used to push new tasks onto the run queue, while the block on function will remove them
and poll them. When a task is woken, it will put itself back on the run queue to be polled
by the executor.
Note: This example trades correctness for simplicity. A real world example would interleave poll calls with calls to an io reactor to wait for events instead of spinning on a loop.
use ;
use Future;
use Pin;
use Rc;
use RefCell;
use VecDeque;
thread_local!
type BoxedFuture = ;
;
block_on;
Required Methods
fn wake(self: Rc<Self>)Wake this task.