1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 00:50:20 +02:00

refactor pipeline

This commit is contained in:
Nikolay Kim
2017-12-01 15:45:15 -08:00
parent 9a1ba527c0
commit 47645626c4
7 changed files with 745 additions and 762 deletions

View File

@@ -12,12 +12,16 @@ use actix::fut::ActorFuture;
use actix::dev::{AsyncContextApi, ActorAddressCell, ActorItemsCell, ActorWaitCell, SpawnHandle,
Envelope, ToEnvelope, RemoteEnvelope};
use task::{IoContext, DrainFut};
use body::{Body, Binary};
use error::Error;
use httprequest::HttpRequest;
use httpresponse::HttpResponse;
use pipeline::DrainFut;
pub(crate) trait IoContext: 'static {
fn disconnected(&mut self);
fn poll(&mut self) -> Poll<Option<Frame>, Error>;
}
#[derive(Debug)]
pub(crate) enum Frame {
@@ -45,6 +49,7 @@ impl<A, S> ActorContext for HttpContext<A, S> where A: Actor<Context=Self>
{
/// Stop actor execution
fn stop(&mut self) {
self.stream.push_back(Frame::Payload(None));
self.items.stop();
self.address.close();
if self.state == ActorState::Running {
@@ -150,6 +155,11 @@ impl<A, S> HttpContext<A, S> where A: Actor<Context=Self> {
}
}
/// Indicate end of streamimng payload. Also this method calls `Self::close`.
pub fn write_eof(&mut self) {
self.stop();
}
/// Returns drain future
pub fn drain(&mut self) -> Drain<A> {
let fut = Rc::new(RefCell::new(DrainFut::default()));