iced/futures/src/executor/tokio.rs
2020-01-20 09:49:17 +01:00

20 lines
486 B
Rust

use crate::Executor;
use futures::Future;
/// The `tokio` runtime.
pub type Tokio = tokio::runtime::Runtime;
impl Executor for Tokio {
fn new() -> Result<Self, futures::io::Error> {
tokio::runtime::Runtime::new()
}
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
let _ = tokio::runtime::Runtime::spawn(self, future);
}
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
tokio::runtime::Runtime::enter(self, f)
}
}