pub struct JoinMapBuilder<'a, K, V, S> { /* private fields */ }tokio_unstable and crate feature rt and crate feature tracing only.Expand description
A variant of task::Builder that spawns tasks on a JoinMap rather than on the current
default runtime.
Implementations§
Source§impl<'a, K, V, S> Builder<'a, K, V, S>
impl<'a, K, V, S> Builder<'a, K, V, S>
Sourcepub fn spawn<F>(self, key: K, task: F) -> Result<()>
pub fn spawn<F>(self, key: K, task: F) -> Result<()>
Spawn the provided task with this builder’s settings and store it in this JoinMap with
the provided key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.
§Panics
This method panics if called outside of a Tokio runtime.
Sourcepub fn spawn_on<F>(&mut self, key: K, task: F, handle: &Handle) -> Result<()>
pub fn spawn_on<F>(&mut self, key: K, task: F, handle: &Handle) -> Result<()>
Spawn the provided task on the provided runtime and store it in this
JoinMap with the provided key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.
Sourcepub fn spawn_blocking<F>(&mut self, key: K, f: F) -> Result<()>
pub fn spawn_blocking<F>(&mut self, key: K, f: F) -> Result<()>
Spawn the blocking code on the blocking threadpool and store it in this JoinMap with the provided
key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.
Note that blocking tasks cannot be cancelled after execution starts. Replaced blocking tasks will still run to completion if the task has begun to execute when it is replaced. A blocking task which is replaced before it has been scheduled on a blocking worker thread will be cancelled.
§Panics
This method panics if called outside of a Tokio runtime.
Sourcepub fn spawn_blocking_on<F>(
&mut self,
key: K,
f: F,
handle: &Handle,
) -> Result<()>
pub fn spawn_blocking_on<F>( &mut self, key: K, f: F, handle: &Handle, ) -> Result<()>
Spawn the blocking code on the blocking threadpool of the provided runtime and store it in this
JoinMap with the provided key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.
Note that blocking tasks cannot be cancelled after execution starts. Replaced blocking tasks will still run to completion if the task has begun to execute when it is replaced. A blocking task which is replaced before it has been scheduled on a blocking worker thread will be cancelled.
Sourcepub fn spawn_local<F>(&mut self, key: K, task: F) -> Result<()>where
F: Future<Output = V> + 'static,
pub fn spawn_local<F>(&mut self, key: K, task: F) -> Result<()>where
F: Future<Output = V> + 'static,
Spawn the provided task on the current LocalSet and store it in this
JoinMap with the provided key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.
§Panics
This method panics if it is called outside of a LocalSet.
Sourcepub fn spawn_local_on<F>(
&mut self,
key: K,
task: F,
local_set: &LocalSet,
) -> Result<()>where
F: Future<Output = V> + 'static,
pub fn spawn_local_on<F>(
&mut self,
key: K,
task: F,
local_set: &LocalSet,
) -> Result<()>where
F: Future<Output = V> + 'static,
Spawn the provided task on the provided LocalSet and store it in
this JoinMap with the provided key.
If a task previously existed in the JoinMap for this key, that task
will be cancelled and replaced with the new one. The previous task will
be removed from the JoinMap; a subsequent call to join_next will
not return a cancelled JoinError for that task.