pub fn spawn<F>(fut: F) -> JoinHandle<F::Output> ⓘwhere
F: Future + 'static,Expand description
Spawns a future on the current native runtime and returns its join handle.
The future and its output need not be Send. The current system’s
TaskCallbacks wrap the task. Dropping the handle
detaches it unless cancel_on_drop is enabled.
Completion is not guaranteed if the runtime shuts down.
A pending task is cancelled once nothing can wake it: no clone of its
waker is stored and its join handle has been dropped. The runtime then
drops the future on its thread without completing it. For example, a
detached task awaiting std::future::pending(), which discards its
waker, is dropped after its first poll along with everything it owns. A
task that waits must leave its waker with whatever ends the wait. While
the join handle is held, the task stays pending instead. The Tokio and
Compio adapters keep such tasks until the runtime shuts down.
§Panics
Panics if no native runtime is active on the current thread.