pub fn start(&self) {
        let mut timer_heap = MinMaxHeap::<T>::new();

        'outer: loop {
            // take the peek of the min-heap-timer sub now as the sleep time otherwise set timeout as 100
            let timeout = if !timer_heap.is_empty() {
                let peek_min_time = timer_heap.peek_min().unwrap().get_instant();
                let now = Instant::now();
                if peek_min_time > now {
                    peek_min_time - now
                } else {
                    Duration::new(0, 0)
                }
            } else {
                Duration::from_secs(100)
            };

            let set_time = self.timer_seter.recv_timeout(timeout);

            // put the timeval into a timerheap
            // put the TimeoutInfo into a hashmap, K: timeval  V: TimeoutInfo
            if set_time.is_ok() {
                let time_out = set_time.unwrap();
                timer_heap.push(time_out);
            }

            if !timer_heap.is_empty() {
                let now = Instant::now();

                // if some timers are set as the same time, send timeout messages and pop them
                while !timer_heap.is_empty()
                    && now >= timer_heap.peek_min().cloned().unwrap().get_instant()
                {
                    let time_info = timer_heap.pop_min().unwrap();
                    if let Err(e) = self.timer_notify.send(time_info) {
                        warn!("send time notification failed with {:?}", e);
                        break 'outer;
                    };
                }
            }
        }
    }
/// A function to start a timer.
A function to start a timer.
A function to start a timer .
pub fn start(&self) {
        let mut timer_heap = MinMaxHeap::<T>::new();
        'outer: loop {
            // take the peek of the min-heap-timer sub now as the sleep time otherwise set timeout as 100
            let timeout = if !timer_heap.is_empty() {
                let peek_min_time = timer_heap.peek_min().unwrap().get_instant();
                let now = Instant::now();
                if peek_min_time > now {
                    peek_min_time - now
                } else {
                    Duration::new(0, 0)
                }
            } else {
                Duration::from_secs(100)
            };
            let set_time = self.timer_seter.recv_timeout(timeout);
            // put the timeval into a timerheap
            // put the TimeoutInfo into a hashmap, K: timeval  V: TimeoutInfo
            if set_time.is_ok() {
                let time_out = set_time.unwrap();
                timer_heap.push(time_out);
            }
            if !timer_heap.is_empty() {
                let now = Instant::now();
                // if some timers are set as the same time, send timeout messages and pop them
                while !timer_heap.is_empty()
                    && now >= timer_heap.peek_min().cloned().unwrap().get_instant()
                {
                    let time_info = timer_heap.pop_min().unwrap();
                    if let Err(e) = self.timer_notify.send(time_info) {
                        warn!("send time notification failed with {:?}", e);
                        break 'outer;
                    };
                }
            }
        }
    }
pub fn start ( & self ) { let mut timer_heap = MinMaxHeap :: < T > :: new ( ) ; ' outer : loop { // take the peek of the min-heap-timer sub now as the sleep time otherwise set timeout as 100 let timeout = if ! timer_heap . is_empty ( ) { let peek_min_time = timer_heap . peek_min ( ) . unwrap ( ) . get_instant ( ) ; let now = Instant :: now ( ) ; if peek_min_time > now { peek_min_time - now } else { Duration :: new ( 0 , 0 ) } } else { Duration :: from_secs ( 100 ) } ; let set_time = self . timer_seter . recv_timeout ( timeout ) ; // put the timeval into a timerheap // put the TimeoutInfo into a hashmap, K: timeval  V: TimeoutInfo if set_time . is_ok ( ) { let time_out = set_time . unwrap ( ) ; timer_heap . push ( time_out ) ; } if ! timer_heap . is_empty ( ) { let now = Instant :: now ( ) ; // if some timers are set as the same time, send timeout messages and pop them while ! timer_heap . is_empty ( ) && now >= timer_heap . peek_min ( ) . cloned ( ) . unwrap ( ) . get_instant ( ) { let time_info = timer_heap . pop_min ( ) . unwrap ( ) ; if let Err ( e ) = self . timer_notify . send ( time_info ) { warn ! ( " " e ) ; break ' outer ; } ; } } } }
A function to start a timer.
A function to start a timer .
&self
&self