Implement WasmBindgen executor and reorganize
This commit is contained in:
parent
90690702e1
commit
04086a90c9
11 changed files with 176 additions and 110 deletions
|
|
@ -4,23 +4,29 @@ mod null;
|
|||
#[cfg(feature = "thread-pool")]
|
||||
mod thread_pool;
|
||||
|
||||
#[cfg(feature = "thread-pool")]
|
||||
pub use thread_pool::ThreadPool;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
mod tokio;
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
mod async_std;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod wasm_bindgen;
|
||||
|
||||
pub use null::Null;
|
||||
|
||||
#[cfg(feature = "thread-pool")]
|
||||
pub use thread_pool::ThreadPool;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use self::tokio::Tokio;
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
pub use self::async_std::AsyncStd;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub use wasm_bindgen::WasmBindgen;
|
||||
|
||||
use futures::Future;
|
||||
|
||||
pub trait Executor: Sized {
|
||||
|
|
|
|||
17
futures/src/executor/wasm_bindgen.rs
Normal file
17
futures/src/executor/wasm_bindgen.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use crate::Executor;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WasmBindgen;
|
||||
|
||||
impl Executor for WasmBindgen {
|
||||
fn new() -> Result<Self, futures::io::Error> {
|
||||
Ok(Self)
|
||||
}
|
||||
|
||||
fn spawn(
|
||||
&self,
|
||||
future: impl futures::Future<Output = ()> + Send + 'static,
|
||||
) {
|
||||
wasm_bindgen_futures::spawn_local(future);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue