Struct futures::task::Context
[−]
[src]
pub struct Context<'a> { /* fields omitted */ }
Information about the currently-running task.
Contexts are always tied to the stack, since they are set up specifically
when performing a single poll
step on a task.
Methods
impl<'a> Context<'a>
[src]
pub fn waker(&self) -> Waker
[src]
Get the Waker
associated with the current task.
The waker can subsequently be used to wake up the task when some event of interest has happened.
pub fn with_waker(&'b mut self, waker: &'b Waker) -> Context<'b>
[src]
Produce a context like the current one, but using the given waker instead.
This advanced method is primarily used when building "internal schedulers" within a task, where you want to provide some customized wakeup logic.
pub fn with_locals(&'b mut self, map: &'b mut LocalMap) -> Context<'b>
[src]
Produce a context like the current one, but using the given task locals instead.
This advanced method is primarily used when building "internal schedulers" within a task.
impl<'a> Context<'a>
[src]
pub fn new(
map: &'a mut LocalMap,
waker: &'a Waker,
executor: &'a mut (Executor + 'a)
) -> Context<'a>
[src]
map: &'a mut LocalMap,
waker: &'a Waker,
executor: &'a mut (Executor + 'a)
) -> Context<'a>
Create a new task context.
Task contexts are always equipped with:
- Task-local data
- A means of waking the task
- A means of spawning new tasks, i.e. an executor
pub fn executor(&mut self) -> &mut Executor
[src]
Get the default executor associated with this task.
This method is useful primarily if you want to explicitly handle spawn failures.
pub fn spawn<F>(&mut self, f: F) where
F: Future<Item = (), Error = Never> + 'static + Send,
[src]
F: Future<Item = (), Error = Never> + 'static + Send,
Spawn a future onto the default executor.
Panics
This method will panic if the default executor is unable to spawn. To handle executor errors, use executor() instead.