mirror of https://github.com/stjepang/smol
Spawn onto local worker if possible
This commit is contained in:
parent
9e1a374559
commit
21fc108621
10
src/task.rs
10
src/task.rs
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue