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

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

Loading…
Cancel
Save