fn interval() {
        let now = SystemTime::now();
        let mut maps = GLOBAL_MAPS.lock().unwrap();

        let mut idx = 0;
        while idx < maps.len() {

            // See if the owning Arc still is around, then lock.
            let opt_arc = maps[idx].upgrade();
            let mut opt_db = match opt_arc.as_ref() {
                Some(arc) => {
                    // Upgrade to strong reference succeeded, now lock inner entry.
                    arc.lock().unwrap()
                },
                None => {
                    // This is a weak reference and the original Arc is gone.
                    maps.remove(idx);
                    continue;
                }
            };

            // See if there still is an inner GdbmDb.
            let db = match opt_db.as_mut() {
                Some(db) => db,
                None => {
                    // No inner GdbmDb anymore.
                    maps.remove(idx);
                    continue;
                },
            };

            // Older than 5 secs, remove.
            if let Ok(d) = now.duration_since(db.lastused) {
                if d.as_secs() > 5 {
                    opt_db.take();
                    maps.remove(idx);
                    continue;
                }
            }

            idx += 1;
        }
    }
// called every second. See if any cached GdbmDb handle has been
// unused for more than 5 seconds, if so, drop it.
called every second. See if any cached GdbmDb handle has been
unused for more than 5 seconds, if so, drop it.
called every second . See if any cached GdbmDb handle has been unused for more than 5 seconds if so drop it .
fn interval() {
        let now = SystemTime::now();
        let mut maps = GLOBAL_MAPS.lock().unwrap();
        let mut idx = 0;
        while idx < maps.len() {
            // See if the owning Arc still is around, then lock.
            let opt_arc = maps[idx].upgrade();
            let mut opt_db = match opt_arc.as_ref() {
                Some(arc) => {
                    // Upgrade to strong reference succeeded, now lock inner entry.
                    arc.lock().unwrap()
                },
                None => {
                    // This is a weak reference and the original Arc is gone.
                    maps.remove(idx);
                    continue;
                }
            };
            // See if there still is an inner GdbmDb.
            let db = match opt_db.as_mut() {
                Some(db) => db,
                None => {
                    // No inner GdbmDb anymore.
                    maps.remove(idx);
                    continue;
                },
            };
            // Older than 5 secs, remove.
            if let Ok(d) = now.duration_since(db.lastused) {
                if d.as_secs() > 5 {
                    opt_db.take();
                    maps.remove(idx);
                    continue;
                }
            }
            idx += 1;
        }
    }
fn interval ( ) { let now = SystemTime :: now ( ) ; let mut maps = GLOBAL_MAPS . lock ( ) . unwrap ( ) ; let mut idx = 0 ; while idx < maps . len ( ) { // See if the owning Arc still is around, then lock. let opt_arc = maps [ idx ] . upgrade ( ) ; let mut opt_db = match opt_arc . as_ref ( ) { Some ( arc ) => { // Upgrade to strong reference succeeded, now lock inner entry. arc . lock ( ) . unwrap ( ) } , None => { // This is a weak reference and the original Arc is gone. maps . remove ( idx ) ; continue ; } } ; // See if there still is an inner GdbmDb. let db = match opt_db . as_mut ( ) { Some ( db ) => db , None => { // No inner GdbmDb anymore. maps . remove ( idx ) ; continue ; } , } ; // Older than 5 secs, remove. if let Ok ( d ) = now . duration_since ( db . lastused ) { if d . as_secs ( ) > 5 { opt_db . take ( ) ; maps . remove ( idx ) ; continue ; } } idx += 1 ; } }
called every second.
called every second .