switch to blocking

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
pull/836/head
Marc-Antoine Perennou 5 years ago
parent 25e0e1abdc
commit 2fe087bd0a

@ -26,6 +26,7 @@ default = [
"std", "std",
"async-io", "async-io",
"async-task", "async-task",
"blocking",
"kv-log-macro", "kv-log-macro",
"log", "log",
"num_cpus", "num_cpus",
@ -79,6 +80,7 @@ surf = { version = "1.0.3", optional = true }
[target.'cfg(not(target_os = "unknown"))'.dependencies] [target.'cfg(not(target_os = "unknown"))'.dependencies]
async-io = { version = "0.1.5", optional = true } async-io = { version = "0.1.5", optional = true }
blocking = { version = "0.5.0", optional = true }
smol = { version = "0.1.17", optional = true } smol = { version = "0.1.17", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]

@ -1,4 +1,4 @@
use crate::task::{JoinHandle, Task}; use crate::task::{self, JoinHandle};
/// Spawns a blocking task. /// Spawns a blocking task.
/// ///
@ -35,8 +35,5 @@ where
F: FnOnce() -> T + Send + 'static, F: FnOnce() -> T + Send + 'static,
T: Send + 'static, T: Send + 'static,
{ {
once_cell::sync::Lazy::force(&crate::rt::RUNTIME); task::spawn(async move { blocking::unblock!(f()) })
let handle = smol::Task::blocking(async move { f() }).into();
JoinHandle::new(handle, Task::new(None))
} }

Loading…
Cancel
Save