Add Application::Executor associated type
This commit is contained in:
parent
35760ac68f
commit
90690702e1
29 changed files with 195 additions and 72 deletions
36
futures/src/executor.rs
Normal file
36
futures/src/executor.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//! Choose your preferred executor to power a runtime.
|
||||
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;
|
||||
|
||||
pub use null::Null;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use self::tokio::Tokio;
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
pub use self::async_std::AsyncStd;
|
||||
|
||||
use futures::Future;
|
||||
|
||||
pub trait Executor: Sized {
|
||||
fn new() -> Result<Self, futures::io::Error>
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static);
|
||||
|
||||
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
|
||||
f()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue