pub fn spawn<F>(&mut self, name: &'static str, f: F)
    where
        F: FnOnce(ThreadServiceInfo) -> (),
        F: Send + 'static,
    {
        let now = Instant::now();
        let thread_service_info = ThreadServiceInfo {
            name: name,
            up_time: now,
            logger: self.logger.new(o!(::log::KEY_TASK => name)).into_erased(),
        };

        let handler = thread::Builder::new()
            .name(name.to_owned())
            // .stack_size(2 * 1024 * 1024)
            .spawn(move || {
                info!(thread_service_info.logger, "starting task");
                f(thread_service_info)
            })
            .unwrap_or_else(|err| panic!("Cannot spawn thread: {}", err));

        let task = Service::new_handler(name, handler, now);
        self.services.push(task);
    }
/// spawn a service in a thread. the service will run as long as the
/// given function does not return. As soon as the function return
/// the service stop
///
spawn a service in a thread. the service will run as long as the
given function does not return. As soon as the function return
the service stop
spawn a service in a thread . the service will run as long as the given function does not return . As soon as the function return the service stop
pub fn spawn<F>(&mut self, name: &'static str, f: F)
    where
        F: FnOnce(ThreadServiceInfo) -> (),
        F: Send + 'static,
    {
        let now = Instant::now();
        let thread_service_info = ThreadServiceInfo {
            name: name,
            up_time: now,
            logger: self.logger.new(o!(::log::KEY_TASK => name)).into_erased(),
        };
        let handler = thread::Builder::new()
            .name(name.to_owned())
            // .stack_size(2 * 1024 * 1024)
            .spawn(move || {
                info!(thread_service_info.logger, "starting task");
                f(thread_service_info)
            })
            .unwrap_or_else(|err| panic!("Cannot spawn thread: {}", err));
        let task = Service::new_handler(name, handler, now);
        self.services.push(task);
    }
pub fn spawn < F > ( & mut self , name : & ' static str , f : F ) where F : FnOnce ( ThreadServiceInfo ) -> ( ) , F : Send + ' static , { let now = Instant :: now ( ) ; let thread_service_info = ThreadServiceInfo { name : name , up_time : now , logger : self . logger . new ( o ! ( log KEY_TASK name ) ) . into_erased ( ) , } ; let handler = thread :: Builder :: new ( ) . name ( name . to_owned ( ) ) // .stack_size(2 * 1024 * 1024) . spawn ( move | | { info ! ( thread_service_info logger " " ) ; f ( thread_service_info ) } ) . unwrap_or_else ( | err | panic ! ( " " err ) ) ; let task = Service :: new_handler ( name , handler , now ) ; self . services . push ( task ) ; }
spawn a service in a thread.
spawn a service in a thread .
&mut self
name
&'static str
f
F
&mut self
name
&'static str
f
F