Spawn onto local worker if possible

This commit is contained in:
Stjepan Glavina 2020-06-22 20:10:36 +02:00
parent 9e1a374559
commit 21fc108621
1 changed files with 5 additions and 5 deletions

View File

@ -102,11 +102,11 @@ impl<T: Send + 'static> Task<T> {
/// ///
/// [`run()`]: `crate::run()` /// [`run()`]: `crate::run()`
pub fn spawn(future: impl Future<Output = T> + Send + 'static) -> Task<T> { pub fn spawn(future: impl Future<Output = T> + Send + 'static) -> Task<T> {
QUEUE.spawn(future) if WORKER.is_set() {
// WORKER.with(|w| match &*w.borrow() { WORKER.with(|w| w.spawn_local(future))
// None => QUEUE.spawn(future), } else {
// Some(w) => w.spawn(future), QUEUE.spawn(future)
// }) }
} }
/// Spawns a future onto the blocking executor. /// Spawns a future onto the blocking executor.