summaryrefslogtreecommitdiffstats
path: root/futures/src/executor/tokio.rs
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 /futures/src/executor/tokio.rs
parent35760ac68f06e783e64e9048aff0fff6df1c09cf (diff)
downloadiced-90690702e1e4abab804ec91e8ff4183824bec436.tar.gz
iced-90690702e1e4abab804ec91e8ff4183824bec436.tar.bz2
iced-90690702e1e4abab804ec91e8ff4183824bec436.zip
Add `Application::Executor` associated type
Diffstat (limited to 'futures/src/executor/tokio.rs')
-rw-r--r--futures/src/executor/tokio.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/futures/src/executor/tokio.rs b/futures/src/executor/tokio.rs
new file mode 100644
index 00000000..aafa7e7b
--- /dev/null
+++ b/futures/src/executor/tokio.rs
@@ -0,0 +1,19 @@
+use crate::Executor;
+
+use futures::Future;
+
+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)
+ }
+}