pub fn remove_expired(&self) -> usize {
        let (expired_peers, resolved_peers) = {
            let mut leases = self.leases.lock().unwrap();
            let (expired_peers, affected_semaphores) = leases.remove_expired(Instant::now());
            // It is not enough to notify only the requests for the removed peers, as other peers
            // might be able to acquire their locks due to the removal of these.
            let mut resolved_peers = Vec::new();
            for semaphore in affected_semaphores {
                leases.resolve_pending(
                    &semaphore,
                    *self.semaphores.get(&semaphore).unwrap(),
                    &mut resolved_peers,
                )
            }
            (expired_peers, resolved_peers)
        };
        if !expired_peers.is_empty() {
            warn!("Removed {} peers due to expiration.", expired_peers.len());
            self.wakers.resolve_with(&resolved_peers, Ok(()));
            self.wakers
                .resolve_with(&expired_peers, Err(ThrottleError::UnknownPeer));
        }
        expired_peers.len()
    }
/// Removes leases outdated due to timestamp. Wakes threads waiting for pending leases if any
/// leases are removed.
///
/// Returns number of (now removed) expired leases
Removes leases outdated due to timestamp. Wakes threads waiting for pending leases if any
leases are removed.

Returns number of (now removed) expired leases
Removes leases outdated due to timestamp . Wakes threads waiting for pending leases if any leases are removed . Returns number of ( now removed ) expired leases
pub fn remove_expired(&self) -> usize {
        let (expired_peers, resolved_peers) = {
            let mut leases = self.leases.lock().unwrap();
            let (expired_peers, affected_semaphores) = leases.remove_expired(Instant::now());
            // It is not enough to notify only the requests for the removed peers, as other peers
            // might be able to acquire their locks due to the removal of these.
            let mut resolved_peers = Vec::new();
            for semaphore in affected_semaphores {
                leases.resolve_pending(
                    &semaphore,
                    *self.semaphores.get(&semaphore).unwrap(),
                    &mut resolved_peers,
                )
            }
            (expired_peers, resolved_peers)
        };
        if !expired_peers.is_empty() {
            warn!("Removed {} peers due to expiration.", expired_peers.len());
            self.wakers.resolve_with(&resolved_peers, Ok(()));
            self.wakers
                .resolve_with(&expired_peers, Err(ThrottleError::UnknownPeer));
        }
        expired_peers.len()
    }
pub fn remove_expired ( & self ) -> usize { let ( expired_peers , resolved_peers ) = { let mut leases = self . leases . lock ( ) . unwrap ( ) ; let ( expired_peers , affected_semaphores ) = leases . remove_expired ( Instant :: now ( ) ) ; // It is not enough to notify only the requests for the removed peers, as other peers // might be able to acquire their locks due to the removal of these. let mut resolved_peers = Vec :: new ( ) ; for semaphore in affected_semaphores { leases . resolve_pending ( & semaphore , * self . semaphores . get ( & semaphore ) . unwrap ( ) , & mut resolved_peers , ) } ( expired_peers , resolved_peers ) } ; if ! expired_peers . is_empty ( ) { warn ! ( " " expired_peers len ( ) ) ; self . wakers . resolve_with ( & resolved_peers , Ok ( ( ) ) ) ; self . wakers . resolve_with ( & expired_peers , Err ( ThrottleError :: UnknownPeer ) ) ; } expired_peers . len ( ) }
Removes leases outdated due to timestamp.
Removes leases outdated due to timestamp .
&self
&self