tokio: deduplicate spawn_blocking (#3017)

Move common code and tracing integration into Handle

Fixes #2998
Closes #3004

Signed-off-by: Marc-Antoine Perennou <[email protected]>
This commit is contained in:
Marc-Antoine Perennou
2020-10-21 20:00:48 +02:00
committed by GitHub
parent 7d7b79e1d5
commit 7fbfa9b649
4 changed files with 27 additions and 21 deletions
+1 -4
View File
@@ -72,10 +72,7 @@ where
F: FnOnce() -> R + Send + 'static,
{
let rt = context::current().expect("not currently running on the Tokio runtime.");
let (task, handle) = task::joinable(BlockingTask::new(func));
let _ = rt.blocking_spawner.spawn(task, &rt);
handle
rt.spawn_blocking(func)
}
#[allow(dead_code)]