aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-07-09 03:23:17 -0400
committerJesse Luehrs <doy@tozt.net>2019-07-09 03:25:38 -0400
commit9667d37c9043d23def44a236b305b865118c381e (patch)
tree23d3042fb3eeee80b115a25ea43f0ac4a81e6d99 /src/state.rs
parent09396b0ffdc8d4fdee11da7db8b951d3575408d4 (diff)
downloadnbsh-old-9667d37c9043d23def44a236b305b865118c381e.tar.gz
nbsh-old-9667d37c9043d23def44a236b305b865118c381e.zip
the state shouldn't exit if there is a polling error
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/state.rs b/src/state.rs
index b9707c0..f6c8a78 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -104,13 +104,8 @@ impl State {
eprint!("command exited: {}\r\n", status);
Ok(())
}
-}
-
-impl futures::future::Future for State {
- type Item = ();
- type Error = Error;
- fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> {
+ fn poll_with_errors(&mut self) -> futures::Poll<(), Error> {
loop {
let mut did_work = false;
@@ -175,6 +170,22 @@ impl futures::future::Future for State {
}
}
+impl futures::future::Future for State {
+ type Item = ();
+ type Error = ();
+
+ fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> {
+ loop {
+ match self.poll_with_errors() {
+ Ok(a) => return Ok(a),
+ Err(e) => {
+ eprint!("error polling state: {}\r\n", e);
+ }
+ }
+ }
+ }
+}
+
struct Command {
future: crate::eval::Eval,
res: futures::sync::oneshot::Sender<()>,