diff options
Diffstat (limited to 'src/runtime/handle.rs')
-rw-r--r-- | src/runtime/handle.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/handle.rs b/src/runtime/handle.rs index 4f1b4c5..173f0ca 100644 --- a/src/runtime/handle.rs +++ b/src/runtime/handle.rs @@ -174,8 +174,11 @@ impl Handle { F: FnOnce() -> R + Send + 'static, R: Send + 'static, { + let fut = BlockingTask::new(func); + #[cfg(all(tokio_unstable, feature = "tracing"))] - let func = { + let fut = { + use tracing::Instrument; #[cfg(tokio_track_caller)] let location = std::panic::Location::caller(); #[cfg(tokio_track_caller)] @@ -193,12 +196,9 @@ impl Handle { kind = %"blocking", function = %std::any::type_name::<F>(), ); - move || { - let _g = span.enter(); - func() - } + fut.instrument(span) }; - let (task, handle) = task::joinable(BlockingTask::new(func)); + let (task, handle) = task::joinable(fut); let _ = self.blocking_spawner.spawn(task, &self); handle } |