pub fn spawn<F>(future: F) -> Task<F::Output> ⓘExpand description
Spawns a task on the runtime this thread is inside, or on the default
runtime. Spawned on a worker, the task stays on that worker unless it
holds more live tasks than another shard by the runtime’s
local_spawn_margin; spawned anywhere
else, it goes to the spawning thread’s home shard by the same rule (the
first spawn takes the less loaded of two shards picked at random). The
task stays on its shard.
Dropping the returned Task cancels it; call Task::detach to let
it run on its own. Awaiting a task that was cancelled (through an
AbortHandle, or by its runtime’s shutdown)
panics; Task::join and Task::fallible answer it instead.
§Panics
When the default runtime or this thread’s shard cannot start (its
poller cannot be made); task::Builder::spawn
answers the error instead.