summaryrefslogtreecommitdiffstats
path: root/futures/src/executor
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--futures/src/executor.rs11
-rw-r--r--futures/src/executor/null.rs4
-rw-r--r--futures/src/executor/wasm_bindgen.rs5
3 files changed, 14 insertions, 6 deletions
diff --git a/futures/src/executor.rs b/futures/src/executor.rs
index 2a5281af..5378c0b3 100644
--- a/futures/src/executor.rs
+++ b/futures/src/executor.rs
@@ -1,7 +1,7 @@
//! Choose your preferred executor to power a runtime.
mod null;
-#[cfg(feature = "thread-pool")]
+#[cfg(all(not(target_arch = "wasm32"), feature = "thread-pool"))]
mod thread_pool;
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
@@ -15,7 +15,7 @@ mod wasm_bindgen;
pub use null::Null;
-#[cfg(feature = "thread-pool")]
+#[cfg(all(not(target_arch = "wasm32"), feature = "thread-pool"))]
pub use thread_pool::ThreadPool;
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
@@ -41,8 +41,15 @@ pub trait Executor: Sized {
/// Spawns a future in the [`Executor`].
///
/// [`Executor`]: trait.Executor.html
+ #[cfg(not(target_arch = "wasm32"))]
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static);
+ /// Spawns a local future in the [`Executor`].
+ ///
+ /// [`Executor`]: trait.Executor.html
+ #[cfg(target_arch = "wasm32")]
+ fn spawn(&self, future: impl Future<Output = ()> + 'static);
+
/// Runs the given closure inside the [`Executor`].
///
/// Some executors, like `tokio`, require some global state to be in place
diff --git a/futures/src/executor/null.rs b/futures/src/executor/null.rs
index 6d5cf982..65e2e2df 100644
--- a/futures/src/executor/null.rs
+++ b/futures/src/executor/null.rs
@@ -11,5 +11,9 @@ impl Executor for Null {
Ok(Self)
}
+ #[cfg(not(target_arch = "wasm32"))]
fn spawn(&self, _future: impl Future<Output = ()> + Send + 'static) {}
+
+ #[cfg(target_arch = "wasm32")]
+ fn spawn(&self, _future: impl Future<Output = ()> + 'static) {}
}
diff --git a/futures/src/executor/wasm_bindgen.rs b/futures/src/executor/wasm_bindgen.rs
index 69b7c7e2..94d694c8 100644
--- a/futures/src/executor/wasm_bindgen.rs
+++ b/futures/src/executor/wasm_bindgen.rs
@@ -9,10 +9,7 @@ impl Executor for WasmBindgen {
Ok(Self)
}
- fn spawn(
- &self,
- future: impl futures::Future<Output = ()> + Send + 'static,
- ) {
+ fn spawn(&self, future: impl futures::Future<Output = ()> + 'static) {
wasm_bindgen_futures::spawn_local(future);
}
}