From 281d8c32d44d8971e0aebf3833a72c02273ac3d2 Mon Sep 17 00:00:00 2001 From: Evgen Druzhynin Date: Mon, 20 Nov 2017 18:53:38 +0200 Subject: [PATCH] Change a return value of reactor::poll to io::Result. --- src/reactor/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/reactor/mod.rs b/src/reactor/mod.rs index 44f0afc16..7127abfde 100644 --- a/src/reactor/mod.rs +++ b/src/reactor/mod.rs @@ -182,7 +182,7 @@ impl Core { return Ok(e) } } - future_fired = self.poll(None); + future_fired = self.poll(None).unwrap(); } } @@ -195,17 +195,16 @@ impl Core { /// `loop { lp.turn(None) }` is equivalent to calling `run` with an /// empty future (one that never finishes). pub fn turn(&mut self, max_wait: Option) { - self.poll(max_wait); + self.poll(max_wait).unwrap(); } - fn poll(&mut self, max_wait: Option) -> bool { + fn poll(&mut self, max_wait: Option) -> io::Result { // Block waiting for an event to happen, peeling out how many events // happened. match self.inner.io.poll(&mut self.events, max_wait) { Ok(_) => {} - Err(ref e) if e.kind() == ErrorKind::Interrupted => return false, - // TODO: This should return an io::Result instead of panic. - Err(e) => panic!("error in poll: {}", e), + Err(ref e) if e.kind() == ErrorKind::Interrupted => return Ok(false), + Err(e) => return Err(e), } // Process all the events that came in, dispatching appropriately @@ -223,7 +222,7 @@ impl Core { } } - return fired + return Ok(fired) } fn dispatch(&mut self, token: mio::Token, ready: mio::Ready) {