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§
- Wraps a
JoinHandle
to abort the underlying task when dropped. - Wraps a tokio
JoinHandle
and provides 4 exclusive (i.e. they takeself
ownership) operations:
Traits§
- Extension methods for
JoinHandle
andAbortOnDropHandle
. - Extension methods for
tokio::task::JoinSet
.
Functions§
- Spawns a new asynchronous task with a name.
- Runs the provided closure with a name on a thread where blocking is acceptable.