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

shutdown io streams before exit

This commit is contained in:
Nikolay Kim
2018-01-03 22:43:44 -08:00
parent bf11bfed8e
commit 1f7aee23df
6 changed files with 169 additions and 19 deletions

View File

@@ -93,7 +93,7 @@ impl ServerSettings {
///
/// `H` - request handler
pub struct HttpServer<T, A, H, U>
where H: 'static
where H: HttpHandler + 'static
{
h: Option<Rc<WorkerSettings<H>>>,
io: PhantomData<T>,
@@ -110,11 +110,11 @@ pub struct HttpServer<T, A, H, U>
shutdown_timeout: u16,
}
unsafe impl<T, A, H, U> Sync for HttpServer<T, A, H, U> where H: 'static {}
unsafe impl<T, A, H, U> Send for HttpServer<T, A, H, U> where H: 'static {}
unsafe impl<T, A, H, U> Sync for HttpServer<T, A, H, U> where H: HttpHandler + 'static {}
unsafe impl<T, A, H, U> Send for HttpServer<T, A, H, U> where H: HttpHandler + 'static {}
impl<T: 'static, A: 'static, H, U: 'static> Actor for HttpServer<T, A, H, U> {
impl<T: 'static, A: 'static, H: HttpHandler + 'static, U: 'static> Actor for HttpServer<T, A, H, U> {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
@@ -122,7 +122,7 @@ impl<T: 'static, A: 'static, H, U: 'static> Actor for HttpServer<T, A, H, U> {
}
}
impl<T: 'static, A: 'static, H, U: 'static> HttpServer<T, A, H, U> {
impl<T: 'static, A: 'static, H: HttpHandler + 'static, U: 'static> HttpServer<T, A, H, U> {
fn update_time(&self, ctx: &mut Context<Self>) {
helpers::update_date();
ctx.run_later(Duration::new(1, 0), |slf, ctx| slf.update_time(ctx));