blocking: #[track_caller] for spawn_blocking (#4616)

Annotates spawn_blocking() with #[track_caller] in order to produce the
correct tracing span spawn locations that show the caller as the spawn
point.
This commit is contained in:
Dom 2022-04-13 16:27:58 +01:00 committed by GitHub
parent 252b0fa9d5
commit 221bb94b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,6 +104,7 @@ const KEEP_ALIVE: Duration = Duration::from_secs(10);
/// Runs the provided function on an executor dedicated to blocking operations.
/// Tasks will be scheduled as non-mandatory, meaning they may not get executed
/// in case of runtime shutdown.
#[track_caller]
pub(crate) fn spawn_blocking<F, R>(func: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,