Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Standard Library as Architecture

Arc<SccacheService> lets connection tasks share storage, compiler discovery, statistics, and execution infrastructure. Mutex protects asynchronously updated statistics; RwLock favors repeated compiler-cache reads over rare replacement after an executable changes.

HashMap<PathBuf, Option<CompilerCacheEntry<C>>> records both discovered compilers and negative discovery. Box<dyn Compiler<C>> gives each entry a runtime-selected compiler family, while its box_clone method makes the erased value explicitly cloneable.

Temporary directories own preprocessing and compilation intermediates. Their Drop cleanup is part of correctness: a future may fail or be cancelled at many awaits without leaving every partial file behind.

WaitUntilZero is a small ownership proof. Every connected service owns an ActiveInfo clone. The waiter keeps only Weak; when the last strong owner drops, Info::drop wakes the shutdown future. No separate connection counter can drift away from actual ownership.

The sharpest stdlib boundary is unsafe: inherited GNU jobserver file descriptors may keep a parent build alive, so sccache detects and closes them. The unsafety is isolated because closing the wrong raw descriptor violates process-wide invariants.