summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-02-06 10:21:52 -0600
committerLibravatar GitHub <noreply@github.com>2020-02-06 10:21:52 -0600
commit97c308076ff93d09eb874f8e954aae4c7c5deaf7 (patch)
treec3a4ec76931c8153c932c364fa393e25d39d74f0 /src
parent7b892eb3e11596925a2993bcc4175ac09ff3768a (diff)
parent36e617ae70cc7a86ce998cbd61f6aa702bb42933 (diff)
downloadiced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.tar.gz
iced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.tar.bz2
iced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.zip
Merge pull request #180 from hecrj/feature/web-styling
Custom styling for `iced_web`
Diffstat (limited to '')
-rw-r--r--src/executor.rs34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/executor.rs b/src/executor.rs
index cbbd8283..e31bd93d 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -5,36 +5,49 @@ pub use platform::Default;
#[cfg(not(target_arch = "wasm32"))]
mod platform {
- use iced_winit::{executor::ThreadPool, futures, Executor};
+ use iced_futures::{executor, futures};
+
+ #[cfg(feature = "tokio")]
+ type Executor = executor::Tokio;
+
+ #[cfg(all(not(feature = "tokio"), feature = "async-std"))]
+ type Executor = executor::AsyncStd;
+
+ #[cfg(not(any(feature = "tokio", feature = "async-std")))]
+ type Executor = executor::ThreadPool;
/// A default cross-platform executor.
///
- /// - On native platforms, it will use a `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(ThreadPool);
+ pub struct Default(Executor);
- impl Executor for Default {
+ impl super::Executor for Default {
fn new() -> Result<Self, futures::io::Error> {
- Ok(Default(ThreadPool::new()?))
+ Ok(Default(Executor::new()?))
}
fn spawn(
&self,
future: impl futures::Future<Output = ()> + Send + 'static,
) {
- self.0.spawn(future);
+ let _ = self.0.spawn(future);
}
}
}
#[cfg(target_arch = "wasm32")]
mod platform {
- use iced_web::{executor::WasmBindgen, futures, Executor};
+ use iced_futures::{executor::WasmBindgen, futures, Executor};
/// A default cross-platform executor.
///
- /// - On native platforms, it will use a `iced_futures::executor::ThreadPool`.
+ /// - On native platforms, it will use `iced_futures::executor::ThreadPool`.
/// - On the Web, it will use `iced_futures::executor::WasmBindgen`.
#[derive(Debug)]
pub struct Default(WasmBindgen);
@@ -44,10 +57,7 @@ mod platform {
Ok(Default(WasmBindgen::new()?))
}
- fn spawn(
- &self,
- future: impl futures::Future<Output = ()> + Send + 'static,
- ) {
+ fn spawn(&self, future: impl futures::Future<Output = ()> + 'static) {
self.0.spawn(future);
}
}