pub(crate) async fn drain(&self) {
        info!("shutting down database background workers");

        // This will cancel all background child tasks
        self.shutdown.cancel();

        let handles: Vec<_> = {
            let mut state = self.state.write().expect("mutex poisoned");

            let mut databases = BTreeMap::new();
            std::mem::swap(&mut databases, &mut state.databases);

            databases
                .into_iter()
                .filter_map(|(_, db_state)| {
                    Arc::try_unwrap(db_state)
                        .expect("who else has a DB handle here?!")
                        .join()
                })
                .collect()
        };

        for handle in handles {
            let _ = handle.await;
        }

        info!("database background workers shutdown");
    }
/// Cancels and drains all background worker tasks
Cancels and drains all background worker tasks
Cancels and drains all background worker tasks
pub(crate) async fn drain(&self) {
        info!("shutting down database background workers");
        // This will cancel all background child tasks
        self.shutdown.cancel();
        let handles: Vec<_> = {
            let mut state = self.state.write().expect("mutex poisoned");
            let mut databases = BTreeMap::new();
            std::mem::swap(&mut databases, &mut state.databases);
            databases
                .into_iter()
                .filter_map(|(_, db_state)| {
                    Arc::try_unwrap(db_state)
                        .expect("who else has a DB handle here?!")
                        .join()
                })
                .collect()
        };
        for handle in handles {
            let _ = handle.await;
        }
        info!("database background workers shutdown");
    }
pub ( crate ) async fn drain ( & self ) { info ! ( " " ) ; // This will cancel all background child tasks self . shutdown . cancel ( ) ; let handles : Vec < _ > = { let mut state = self . state . write ( ) . expect ( " " ) ; let mut databases = BTreeMap :: new ( ) ; std :: mem :: swap ( & mut databases , & mut state . databases ) ; databases . into_iter ( ) . filter_map ( | ( _ , db_state ) | { Arc :: try_unwrap ( db_state ) . expect ( " " ) . join ( ) } ) . collect ( ) } ; for handle in handles { let _ = handle . await ; } info ! ( " " ) ; }
Cancels and drains all background worker tasks
Cancels and drains all background worker tasks
&self
&self