/// Prepares a server to handle graceful shutdown when the provided future
/// completes.
///
/// # Example
///
/// ```
/// # extern crate hyper;
/// # extern crate futures;
/// # use futures::Future;
/// # fn main() {}
/// # #[cfg(feature = "runtime")]
/// # fn run() {
/// # use hyper::{Body, Response, Server};
/// # use hyper::service::service_fn_ok;
/// # let new_service = || {
/// #     service_fn_ok(|_req| {
/// #         Response::new(Body::from("Hello World"))
/// #     })
/// # };
///
/// // Make a server from the previous examples...
/// let server = Server::bind(&([127, 0, 0, 1], 3000).into())
///     .serve(new_service);
///
/// // Prepare some signal for when the server should start
/// // shutting down...
/// let (tx, rx) = futures::sync::oneshot::channel::<()>();
///
/// let graceful = server
///     .with_graceful_shutdown(rx)
///     .map_err(|err| eprintln!("server error: {}", err));
///
/// // Spawn `server` onto an Executor...
/// hyper::rt::spawn(graceful);
///
/// // And later, trigger the signal by calling `tx.send(())`.
/// let _ = tx.send(());
/// # }
/// ```
Prepares a server to handle graceful shutdown when the provided future
completes.
Prepares a server to handle graceful shutdown when the provided future completes .
pub fn with_graceful_shutdown<F>(self, signal: F) -> Graceful<I, S, F, E>
    where
        F: Future<Item=()>
    {
        Graceful::new(self.spawn_all, signal)
    }
pub fn with_graceful_shutdown < F > ( self , signal : F ) -> Graceful < I , S , F , E > where F : Future < Item = ( ) > { Graceful :: new ( self . spawn_all , signal ) }
Prepares a server to handle graceful shutdown when the provided future
completes.
Prepares a server to handle graceful shutdown when the provided future completes .
self
signal
F
example
None
extern crate hyper;
None
extern crate futures;
None
use futures::future;
None
fn main() {}
None
#[cfg(feature = "runtime")]
None
fn run() {
None
use hyper::{body, response, server};
None
use hyper::service::service_fn_ok;
None
let new_service = || {
None
service_fn_ok(|_req| {
None
response::new(body::from("hello world"))
None
})
None
};
Make a server from the previous examples
let server = Server::bind(&([127, 0, 0, 1], 3000).into())
.serve(new_service).

Prepare some signal for when the server should start
shutting down
let (tx, rx) = futures::sync::oneshot::channel::<()>().

let graceful = server
.with_graceful_shutdown(rx)
.map_err(|err| eprintln!("server error: {}", err)).

Spawn `server` onto an Executor
hyper::rt::spawn(graceful).

And later, trigger the signal by calling `tx.send(())`.
Make a server from the previous examples let server = Server :: bind ( & ( [ 127 0 0 1 ] 3000 ) . into () ) . serve ( new_service ) . Prepare some signal for when the server should start shutting down let ( tx rx ) = futures :: sync :: oneshot :: channel :: < () > () . let graceful = server . with_graceful_shutdown ( rx ) . map_err ( |err| eprintln! ( " server error : {} " err )) . Spawn ` server ` onto an Executor hyper :: rt :: spawn ( graceful ) . And later trigger the signal by calling ` tx . send (( )) ` .
}
None