Skip to main content

Module task

Module task 

Source
Expand description

Spawning tokio tasks and OS threads through handles that own them.

spawn and spawn_on start a tokio task and return a TaskHandle, which aborts the task when dropped. spawn_thread starts a named OS thread and returns a ThreadHandle, which joins the thread when dropped. Each spawn takes a name, and a panic in the task or thread is logged at ERROR with that name. The panic still reaches a caller that awaits or joins the handle.

Structs§

TaskHandle
An owned tokio task, aborted when the handle drops.
ThreadHandle
An owned OS thread, joined when the handle drops.

Functions§

panic_text
The text of a panic payload: the message of a &str or String payload, and a fixed placeholder for any other type.
spawn
Spawn future as a task named name on the current tokio runtime.
spawn_on
Spawn future as a task named name on the runtime behind handle.
spawn_thread
Spawn f on a new OS thread named name.