diff --git a/Cargo.toml b/Cargo.toml index 65f65407c..66fd5b856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,8 @@ env_logger = "*" [dependencies.actix] #path = "../actix" -git = "https://github.com/fafhrd91/actix.git" +#git = "https://github.com/fafhrd91/actix.git" +version = "0.2" default-features = false features = [] diff --git a/src/context.rs b/src/context.rs index bcf59122b..ff3d0e05b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -6,7 +6,7 @@ use futures::{Async, Stream, Poll}; use bytes::Bytes; use actix::{Actor, ActorState, ActorContext, AsyncContext}; use actix::fut::ActorFuture; -use actix::dev::{AsyncContextApi, ActorAddressCell, ActorItemsCell, SpawnHandle}; +use actix::dev::{AsyncContextApi, ActorAddressCell, ActorItemsCell, ActorWaitCell, SpawnHandle}; use route::{Route, Frame}; use httpresponse::HttpResponse; @@ -20,7 +20,7 @@ pub struct HttpContext where A: Actor> + Route, items: ActorItemsCell, address: ActorAddressCell, stream: VecDeque, - wait: Option>>, + wait: ActorWaitCell, app_state: Rc<::State>, } @@ -60,7 +60,7 @@ impl AsyncContext for HttpContext where A: Actor + Route fn wait(&mut self, fut: F) where F: ActorFuture + 'static { - self.wait = Some(Box::new(fut)); + self.wait.add(fut); } fn cancel_future(&mut self, handle: SpawnHandle) -> bool { @@ -84,8 +84,8 @@ impl HttpContext where A: Actor + Route { state: ActorState::Started, items: ActorItemsCell::default(), address: ActorAddressCell::default(), + wait: ActorWaitCell::default(), stream: VecDeque::new(), - wait: None, app_state: state, } } @@ -124,7 +124,7 @@ impl Stream for HttpContext where A: Actor + Route type Item = Frame; type Error = std::io::Error; - fn poll(&mut self) -> Poll, Self::Error> { + fn poll(&mut self) -> Poll, std::io::Error> { if self.act.is_none() { return Ok(Async::NotReady) } @@ -148,16 +148,11 @@ impl Stream for HttpContext where A: Actor + Route _ => () } - // check wait future - if self.wait.is_some() && self.act.is_some() { - if let Some(ref mut act) = self.act { - if let Some(ref mut fut) = self.wait { - if let Ok(Async::NotReady) = fut.poll(act, ctx) { - return Ok(Async::NotReady); - } - } + // check wait futures + if let Some(ref mut act) = self.act { + if let Ok(Async::NotReady) = self.wait.poll(act, ctx) { + return Ok(Async::NotReady) } - self.wait = None; } let mut prep_stop = false;