From 90690702e1e4abab804ec91e8ff4183824bec436 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 20 Jan 2020 04:47:36 +0100 Subject: Add `Application::Executor` associated type --- futures/src/executor.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 futures/src/executor.rs (limited to 'futures/src/executor.rs') diff --git a/futures/src/executor.rs b/futures/src/executor.rs new file mode 100644 index 00000000..144a41f8 --- /dev/null +++ b/futures/src/executor.rs @@ -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 + where + Self: Sized; + + fn spawn(&self, future: impl Future + Send + 'static); + + fn enter(&self, f: impl FnOnce() -> R) -> R { + f() + } +} -- cgit