fn with_cache<T>(f: impl FnOnce(&ListCache) -> T) -> T {
    let cache = CACHE.upgradable_read();

    // First check if the list needs to be refreshed.
    if cache.needs_refreshed() {
        // Upgrade our lock to gain write access.
        let mut cache = RwLockUpgradableReadGuard::upgrade(cache);

        // If there was contention then the cache might not need refreshed any
        // more.
        if cache.needs_refreshed() {
            if let Err(e) = cache.refresh() {
                tracing::warn!("could not refresh public suffix list: {}", e);
            }
        }

        f(&*cache)
    } else {
        f(&*cache)
    }
}
/// Execute a given closure with a reference to the list cache. If the list is
/// out of date, attempt to refresh it first before continuing.
Execute a given closure with a reference to the list cache. If the list is
out of date, attempt to refresh it first before continuing.
Execute a given closure with a reference to the list cache . If the list is out of date attempt to refresh it first before continuing .
fn with_cache<T>(f: impl FnOnce(&ListCache) -> T) -> T {
    let cache = CACHE.upgradable_read();
    // First check if the list needs to be refreshed.
    if cache.needs_refreshed() {
        // Upgrade our lock to gain write access.
        let mut cache = RwLockUpgradableReadGuard::upgrade(cache);
        // If there was contention then the cache might not need refreshed any
        // more.
        if cache.needs_refreshed() {
            if let Err(e) = cache.refresh() {
                tracing::warn!("could not refresh public suffix list: {}", e);
            }
        }
        f(&*cache)
    } else {
        f(&*cache)
    }
}
fn with_cache < T > ( f : impl FnOnce ( & ListCache ) -> T ) -> T { let cache = CACHE . upgradable_read ( ) ; // First check if the list needs to be refreshed. if cache . needs_refreshed ( ) { // Upgrade our lock to gain write access. let mut cache = RwLockUpgradableReadGuard :: upgrade ( cache ) ; // If there was contention then the cache might not need refreshed any // more. if cache . needs_refreshed ( ) { if let Err ( e ) = cache . refresh ( ) { tracing :: warn ! ( " " e ) ; } } f ( & * cache ) } else { f ( & * cache ) } }
Execute a given closure with a reference to the list cache.
Execute a given closure with a reference to the list cache .
f
impl FnOnce(&ListCache) -> T