Module task

Source
Available on crate feature async only.
Expand description

Tokio task utilities.

§Named task spawning

The spawn and spawn_blocking methods are wrappers around tokio::task::spawn and tokio::task::spawn_blocking that attach a name the spawned task.

If Clippy sent you here, replace:

tokio::task::spawn(my_future)
tokio::task::spawn_blocking(my_blocking_closure)

with:

mz_ore::task::spawn(|| format!("taskname:{}", info), my_future)
mz_ore::task::spawn_blocking(|| format!("name:{}", info), my_blocking_closure)

If you are using methods of the same names on a Runtime or Handle, import RuntimeExt and replace spawn with RuntimeExt::spawn_named and spawn_blocking with RuntimeExt::spawn_blocking_named, adding naming closures like above.

Structs§

AbortOnDropHandle
Wraps a JoinHandle to abort the underlying task when dropped.
JoinHandle
Wraps a tokio JoinHandle and provides 4 exclusive (i.e. they take self ownership) operations:

Traits§

JoinHandleExt
Extension methods for JoinHandle and AbortOnDropHandle.
JoinSetExt
Extension methods for tokio::task::JoinSet.
RuntimeExt
Extension methods for Runtime and Handle.

Functions§

spawn
Spawns a new asynchronous task with a name.
spawn_blocking
Runs the provided closure with a name on a thread where blocking is acceptable.
unpack_join_result 🔒