summaryrefslogtreecommitdiffstats
path: root/src/native/executor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/native/executor.rs')
-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);
+ }
+}