pub fn with_lock<F: FnOnce() -> R, R>(lock_path: &Path) -> impl FnOnce(F) -> RExpand description
Run f while holding an exclusive cross-process lock on lock_path.
A build script may be invoked concurrently for multiple compile units of the
same crate (e.g. the host-profile build-dep unit and the target-profile unit
of a links crate). This serializes a download/extract block via an
atomic-create lock file so concurrent invocations don’t race on shared
writes; the second waiter typically observes a fresh marker and skips its own
work. A lock held longer than 120 s (e.g. a crashed previous holder) is
treated as stale, removed, and the wait continues.