summaryrefslogtreecommitdiffstats
path: root/futures/src/executor/tokio.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-01-21 00:15:01 +0100
committerLibravatar GitHub <noreply@github.com>2020-01-21 00:15:01 +0100
commit7016221556ea8183ebcd8ef8df00044e2eda71e7 (patch)
treebc1609b71b88437fc7497af339b6427f63121c76 /futures/src/executor/tokio.rs
parent6ca5e6184f9f1c12b427bdafcce0b4e9fbc5bb14 (diff)
parent91d9d65a03ce9b211e4043726e7424949d314325 (diff)
downloadiced-7016221556ea8183ebcd8ef8df00044e2eda71e7.tar.gz
iced-7016221556ea8183ebcd8ef8df00044e2eda71e7.tar.bz2
iced-7016221556ea8183ebcd8ef8df00044e2eda71e7.zip
Merge pull request #164 from hecrj/feature/custom-runtime
Custom futures executor with `iced_futures`
Diffstat (limited to 'futures/src/executor/tokio.rs')
-rw-r--r--futures/src/executor/tokio.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/futures/src/executor/tokio.rs b/futures/src/executor/tokio.rs
new file mode 100644
index 00000000..20802ceb
--- /dev/null
+++ b/futures/src/executor/tokio.rs
@@ -0,0 +1,20 @@
+use crate::Executor;
+
+use futures::Future;
+
+/// A `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)
+ }
+}