cosmic/executor/
multi.rs
1use std::future::Future;
7
8#[cfg(feature = "tokio")]
9pub struct Executor(tokio::runtime::Runtime);
10
11#[cfg(feature = "tokio")]
12impl iced::Executor for Executor {
13 fn new() -> Result<Self, iced::futures::io::Error> {
14 Ok(Self(
15 tokio::runtime::Builder::new_multi_thread()
16 .enable_all()
17 .build()?,
18 ))
19 }
20
21 fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
22 let _res = self.0.spawn(future);
23 }
24
25 fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
26 let _guard = self.0.enter();
27 f()
28 }
29}