Skip to main content

lash_core/
task.rs

1//! Tokio task helpers that preserve the caller's tracing context.
2
3use std::future::Future;
4
5use tracing::Instrument as _;
6
7/// Spawn a Tokio task as a child of the current tracing span.
8#[allow(
9    clippy::disallowed_methods,
10    reason = "this is the single guarded entry point for Tokio task spawning"
11)]
12pub fn spawn<F>(future: F) -> tokio::task::JoinHandle<F::Output>
13where
14    F: Future + Send + 'static,
15    F::Output: Send + 'static,
16{
17    tokio::spawn(future.instrument(tracing::Span::current()))
18}