INNER CODE UNIT · Rust
console_state_lock
psmux/psmux · crates/portable-pty-psmux/src/lib.rs:446
pub fn console_state_lock() -> std::sync::RwLockWriteGuard<'static, ()> {
CONSOLE_STATE.write().unwrap_or_else(|e| e.into_inner())
}
/// How long the last ConPTY spawn on THIS thread spent waiting to get into the
/// console state, in microseconds. Diagnostics only: psmux reads it for its
/// `PSMUX_WARM_TRACE` spawn line so a serialised surge is visible as wait time
/// rather than guessed at.
pub fn last_spawn_console_wait_us() -> u64 {
SPAWN_WAIT_US.with(|c| c.get())
}
thread_local! {
static SPAWN_WAIT_US: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
}
/// Shared, refcounted entry into the console state for a ConPTY spawn.
///