pub fn spawn_future<F, T>(&mut self, name: &'static str, f: F)
    where
        F: FnOnce(TokioServiceInfo) -> T,
        T: Future<Item = (), Error = ()> + Send + 'static,
    {
        let mut runtime = runtime::Builder::new()
            .keep_alive(None)
            .name_prefix(name)
            .build()
            .unwrap();

        let executor = runtime.executor();

        let now = Instant::now();
        let future_service_info = TokioServiceInfo {
            name: name,
            up_time: now,
            logger: self.logger.new(o!(::log::KEY_TASK => name)).into_erased(),
            executor: executor,
        };

        use std::panic::AssertUnwindSafe;

        let future = AssertUnwindSafe(f(future_service_info))
            .catch_unwind()
            .map(|_| ())
            .map_err(|err| {
                if let Some(string) = err.downcast_ref::<String>() {
                    eprintln!("{}", string);
                }
                std::process::exit(66);
            });

        runtime.spawn(future);

        let task = Service::new_runtime(name, runtime, now);
        self.services.push(task);
    }
/// Spawn the given Future in a new dedicated runtime
Spawn the given Future in a new dedicated runtime
Spawn the given Future in a new dedicated runtime
pub fn spawn_future<F, T>(&mut self, name: &'static str, f: F)
    where
        F: FnOnce(TokioServiceInfo) -> T,
        T: Future<Item = (), Error = ()> + Send + 'static,
    {
        let mut runtime = runtime::Builder::new()
            .keep_alive(None)
            .name_prefix(name)
            .build()
            .unwrap();
        let executor = runtime.executor();
        let now = Instant::now();
        let future_service_info = TokioServiceInfo {
            name: name,
            up_time: now,
            logger: self.logger.new(o!(::log::KEY_TASK => name)).into_erased(),
            executor: executor,
        };
        use std::panic::AssertUnwindSafe;
        let future = AssertUnwindSafe(f(future_service_info))
            .catch_unwind()
            .map(|_| ())
            .map_err(|err| {
                if let Some(string) = err.downcast_ref::<String>() {
                    eprintln!("{}", string);
                }
                std::process::exit(66);
            });
        runtime.spawn(future);
        let task = Service::new_runtime(name, runtime, now);
        self.services.push(task);
    }
pub fn spawn_future < F , T > ( & mut self , name : & ' static str , f : F ) where F : FnOnce ( TokioServiceInfo ) -> T , T : Future < Item = ( ) , Error = ( ) > + Send + ' static , { let mut runtime = runtime :: Builder :: new ( ) . keep_alive ( None ) . name_prefix ( name ) . build ( ) . unwrap ( ) ; let executor = runtime . executor ( ) ; let now = Instant :: now ( ) ; let future_service_info = TokioServiceInfo { name : name , up_time : now , logger : self . logger . new ( o ! ( log KEY_TASK name ) ) . into_erased ( ) , executor : executor , } ; use std :: panic :: AssertUnwindSafe ; let future = AssertUnwindSafe ( f ( future_service_info ) ) . catch_unwind ( ) . map ( | _ | ( ) ) . map_err ( | err | { if let Some ( string ) = err . downcast_ref :: < String > ( ) { eprintln ! ( " " string ) ; } std :: process :: exit ( 66 ) ; } ) ; runtime . spawn ( future ) ; let task = Service :: new_runtime ( name , runtime , now ) ; self . services . push ( task ) ; }
Spawn the given Future in a new dedicated runtime
Spawn the given Future in a new dedicated runtime
&mut self
name
&'static str
f
F
&mut self
name
&'static str
f
F