1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-11 17:59:35 +00:00

added new cancel_future_on_stop

This commit is contained in:
Nikolay Kim 2017-10-30 14:49:20 -07:00
parent e3c058c96e
commit 58de9dcf56
4 changed files with 11 additions and 6 deletions

View file

@ -15,7 +15,7 @@ build = "build.rs"
[badges]
travis-ci = { repository = "actix/actix-web", branch = "master" }
appveyor = { repository = "fafhrd91/actix-web-hdy9d" }
appveyor = { repository = "actix/actix-web" }
codecov = { repository = "actix/actix-web", branch = "master", service = "github" }
[lib]

View file

@ -110,7 +110,6 @@ fn main() {
.route_handler("/", StaticFiles::new("examples/static/", true)))
.serve::<_, ()>("127.0.0.1:8080").unwrap();
println!("Started http server: 127.0.0.1:8080");
Arbiter::system().send(msgs::SystemExit(0));
let _ = sys.run();
}

View file

@ -211,10 +211,10 @@ fn main() {
// redirect to websocket.html
.resource("/", |r|
r.handler(Method::GET, |req, payload, state| {
httpcodes::HTTPFound
.builder()
.header("LOCATION", "/static/websocket.html")
.body(Body::Empty)
Ok(httpcodes::HTTPFound
.builder()
.header("LOCATION", "/static/websocket.html")
.body(Body::Empty)?)
}))
// websocket
.resource("/ws/", |r| r.get::<WsChatSession>())

View file

@ -35,6 +35,7 @@ pub struct HttpContext<A> where A: Actor<Context=HttpContext<A>> + Route,
impl<A> IoContext for HttpContext<A> where A: Actor<Context=Self> + Route {
fn disconnected(&mut self) {
self.items.stop();
self.disconnected = true;
if self.state == ActorState::Running {
self.state = ActorState::Stopping;
@ -46,6 +47,7 @@ impl<A> ActorContext for HttpContext<A> where A: Actor<Context=Self> + Route
{
/// Stop actor execution
fn stop(&mut self) {
self.items.stop();
self.address.close();
if self.state == ActorState::Running {
self.state = ActorState::Stopping;
@ -85,6 +87,10 @@ impl<A> AsyncContext<A> for HttpContext<A> where A: Actor<Context=Self> + Route
self.modified = true;
self.items.cancel_future(handle)
}
fn cancel_future_on_stop(&mut self, handle: SpawnHandle) {
self.items.cancel_future_on_stop(handle)
}
}
#[doc(hidden)]