diff options
Diffstat (limited to '')
-rw-r--r-- | futures/src/runtime.rs (renamed from core/src/runtime.rs) | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/src/runtime.rs b/futures/src/runtime.rs index 31234d11..bc1ad8ac 100644 --- a/core/src/runtime.rs +++ b/futures/src/runtime.rs @@ -1,3 +1,4 @@ +//! Run commands and subscriptions. mod executor; pub use executor::Executor; @@ -10,8 +11,8 @@ use std::marker::PhantomData; #[derive(Debug)] pub struct Runtime<Hasher, Event, Executor, Receiver, Message> { executor: Executor, - subscriptions: subscription::Tracker<Hasher, Event>, receiver: Receiver, + subscriptions: subscription::Tracker<Hasher, Event>, _message: PhantomData<Message>, } @@ -28,15 +29,19 @@ where + 'static, Message: Send + 'static, { - pub fn new(receiver: Receiver) -> Self { + pub fn new(executor: Executor, receiver: Receiver) -> Self { Self { - executor: Executor::new(), - subscriptions: subscription::Tracker::new(), + executor, receiver, + subscriptions: subscription::Tracker::new(), _message: PhantomData, } } + pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R { + self.executor.enter(f) + } + pub fn spawn(&mut self, command: Command<Message>) { use futures::{FutureExt, SinkExt}; |