INNER CODE UNIT · Rust

clear_pools

hcavarsan/kftray · crates/kftray-commons/src/lib.rs:41

    fn clear_pools() {
        crate::utils::db::clear_db_pool();
        crate::utils::db_mode::DatabaseManager::cleanup_memory_pools();
    }

    /// Serializes environment-variable mutation across tests: `std::env` is
    /// global to the process, so two tests mutating it on different threads
    /// must not interleave.
    static ENV_MUTEX: Mutex<()> = Mutex::new(());

    thread_local! {
        // Depth of `EnvVarGuard`s already holding `ENV_MUTEX` on this
        // thread. A test commonly builds up several guards at once, one per
        // variable; a plain, non-reentrant lock would deadlock the second
        // guard against the first held by the same thread.
        static ENV_LOCK_DEPTH: Cell<usize> = const { Cell::new(0) };
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…