INNER CODE UNIT · Rust

acquire

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

        fn acquire() -> Self {
            let depth = ENV_LOCK_DEPTH.with(Cell::get);
            ENV_LOCK_DEPTH.with(|cell| cell.set(depth + 1));
            if depth == 0 {
                EnvLock::Owned {
                    _guard: ENV_MUTEX.lock().unwrap_or_else(|error| error.into_inner()),
                }
            } else {
                EnvLock::Nested
            }
        }
    }

    impl Drop for EnvLock {
        fn drop(&mut self) {
            let depth = ENV_LOCK_DEPTH.with(Cell::get);
            if let EnvLock::Owned { .. } = self {
                debug_assert_eq!(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…