summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/executor.rs b/src/executor.rs
index b4be5264..0333bc1d 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -1,5 +1,5 @@
//! Choose your preferred executor to power your application.
-pub use crate::common::{executor::Null, Executor};
+pub use crate::runtime::Executor;
pub use platform::Default;
@@ -7,13 +7,23 @@ pub use platform::Default;
mod platform {
use iced_futures::{executor, futures};
- #[cfg(feature = "tokio")]
+ #[cfg(feature = "tokio_old")]
+ type Executor = executor::TokioOld;
+
+ #[cfg(all(not(feature = "tokio_old"), feature = "tokio"))]
type Executor = executor::Tokio;
- #[cfg(all(not(feature = "tokio"), feature = "async-std"))]
+ #[cfg(all(
+ not(any(feature = "tokio_old", feature = "tokio")),
+ feature = "async-std"
+ ))]
type Executor = executor::AsyncStd;
- #[cfg(not(any(feature = "tokio", feature = "async-std")))]
+ #[cfg(not(any(
+ feature = "tokio_old",
+ feature = "tokio",
+ feature = "async-std"
+ )))]
type Executor = executor::ThreadPool;
/// A default cross-platform executor.
@@ -40,7 +50,7 @@ mod platform {
}
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
- self.0.enter(f)
+ super::Executor::enter(&self.0, f)
}
}
}
@@ -51,7 +61,11 @@ mod platform {
/// A default cross-platform executor.
///
- /// - On native platforms, it will use `iced_futures::executor::ThreadPool`.
+ /// - On native platforms, it will use:
+ /// - `iced_futures::executor::Tokio` when the `tokio` feature is enabled.
+ /// - `iced_futures::executor::AsyncStd` when the `async-std` feature is
+ /// enabled.
+ /// - `iced_futures::executor::ThreadPool` otherwise.
/// - On the Web, it will use `iced_futures::executor::WasmBindgen`.
#[derive(Debug)]
pub struct Default(WasmBindgen);
@@ -64,5 +78,9 @@ mod platform {
fn spawn(&self, future: impl futures::Future<Output = ()> + 'static) {
self.0.spawn(future);
}
+
+ fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
+ self.0.enter(f)
+ }
}
}