pub fn start(state: Arc<State>, interval: Duration) -> LitterCollection {
    let stopped = Arc::new((Mutex::new(false), Condvar::new()));
    info!("Start litter collection with interval: {:?}", interval);
    // Copy of stopped for litter collecting thread
    let canceled = stopped.clone();
    let handle = spawn(move || {
        loop {
            let done = canceled.0.lock().unwrap();
            let done = {
                // Introduce extra scope here, so we do not hold lock to done during execution
                // of removed_expired.
                let (done, _wait_timeout_result) = canceled.1.wait_timeout(done, interval).unwrap();
                *done
            };
            if done {
                break;
            } else {
                let num_removed = state.remove_expired();
                if num_removed == 0 {
                    debug!("Litter collection did not find any expired leases.")
                } else {
                    warn!("Litter collection removed {} expired leases", num_removed);
                }
            }
        }
    });
    LitterCollection { stopped, handle }
}
/// Starts a new thread that removes expired leases.
Starts a new thread that removes expired leases.
Starts a new thread that removes expired leases .
pub fn start(state: Arc<State>, interval: Duration) -> LitterCollection {
    let stopped = Arc::new((Mutex::new(false), Condvar::new()));
    info!("Start litter collection with interval: {:?}", interval);
    // Copy of stopped for litter collecting thread
    let canceled = stopped.clone();
    let handle = spawn(move || {
        loop {
            let done = canceled.0.lock().unwrap();
            let done = {
                // Introduce extra scope here, so we do not hold lock to done during execution
                // of removed_expired.
                let (done, _wait_timeout_result) = canceled.1.wait_timeout(done, interval).unwrap();
                *done
            };
            if done {
                break;
            } else {
                let num_removed = state.remove_expired();
                if num_removed == 0 {
                    debug!("Litter collection did not find any expired leases.")
                } else {
                    warn!("Litter collection removed {} expired leases", num_removed);
                }
            }
        }
    });
    LitterCollection { stopped, handle }
}
pub fn start ( state : Arc < State > , interval : Duration ) -> LitterCollection { let stopped = Arc :: new ( ( Mutex :: new ( false ) , Condvar :: new ( ) ) ) ; info ! ( " " interval ) ; // Copy of stopped for litter collecting thread let canceled = stopped . clone ( ) ; let handle = spawn ( move | | { loop { let done = canceled . 0 . lock ( ) . unwrap ( ) ; let done = { // Introduce extra scope here, so we do not hold lock to done during execution // of removed_expired. let ( done , _wait_timeout_result ) = canceled . 1 . wait_timeout ( done , interval ) . unwrap ( ) ; * done } ; if done { break ; } else { let num_removed = state . remove_expired ( ) ; if num_removed == 0 { debug ! ( " " ) } else { warn ! ( " " num_removed ) ; } } } } ) ; LitterCollection { stopped , handle } }
Starts a new thread that removes expired leases.
Starts a new thread that removes expired leases .
state
Arc<State>
interval
Duration
state
Arc<State>
interval
Duration