[−][src]Function task_scope::spawn::tokio::spawn
pub fn spawn<F>(task: F) -> SpawnFuture<F>
Creates a future that spawns the given task in the current scope.
This function is available when "tokio"
feature is enabled.
spawn
function does not spawn a new task immediately. Instead, it returns a future for
spawning the given task. Currently, the returned future will spawn the task at the first
poll, but future versions may defer the spawn (e.g. rate limiting new tasks).
A graceful cancellation request will be propagated to the spawned task. If the scope is forcibly canceled, the spawned task will not be resumed after the next cancellation point.
Returns
The returned future resolves to JoinHandle
for the spawned task.
JoinHandle
can be used to wait for the completion of the task.
Panics
The returned future panics when polled outside of a scope or after the spawning.