summaryrefslogtreecommitdiffstats
path: root/src/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-20 04:47:36 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-20 04:47:36 +0100
commit90690702e1e4abab804ec91e8ff4183824bec436 (patch)
treed3f989047f4ac5166bc5baed9febcc10af2d63a6 /src/native
parent35760ac68f06e783e64e9048aff0fff6df1c09cf (diff)
downloadiced-90690702e1e4abab804ec91e8ff4183824bec436.tar.gz
iced-90690702e1e4abab804ec91e8ff4183824bec436.tar.bz2
iced-90690702e1e4abab804ec91e8ff4183824bec436.zip
Add `Application::Executor` associated type
Diffstat (limited to 'src/native')
-rw-r--r--src/native/executor.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/native/executor.rs b/src/native/executor.rs
new file mode 100644
index 00000000..68a1d280
--- /dev/null
+++ b/src/native/executor.rs
@@ -0,0 +1,23 @@
+//! Choose your preferred executor to power your application.
+pub use iced_winit::{executor::Null, Executor};
+use iced_winit::{executor::ThreadPool, futures};
+
+/// The default cross-platform executor.
+///
+/// - On native platforms, it will use a `ThreadPool`.
+/// - On the Web, it will use `wasm-bindgen-futures::spawn_local`.
+#[derive(Debug)]
+pub struct Default(ThreadPool);
+
+impl Executor for Default {
+ fn new() -> Result<Self, futures::io::Error> {
+ Ok(Default(ThreadPool::new()?))
+ }
+
+ fn spawn(
+ &self,
+ future: impl futures::Future<Output = ()> + Send + 'static,
+ ) {
+ self.0.spawn(future);
+ }
+}