Expand description
Counting semaphore via lock files to limit parallel invocations (see lock::acquire_cli_slot).
Counting semaphore via lock files to limit parallel CLI invocations.
acquire_cli_slot tries to acquire one of N available slots by opening the file
cli-slot-{N}.lock in the OS cache directory and obtaining an exclusive flock.
The returned std::fs::File MUST be kept alive for the entire duration of main;
dropping it releases the slot automatically for the next invocation.
When wait_seconds is Some(n) > 0, the function polls every
crate::constants::CLI_LOCK_POLL_INTERVAL_MS milliseconds until the deadline. When it
is None or Some(0), a single attempt is made and Err(AppError::AllSlotsFull) is
returned immediately if all slots are occupied.
Functionsยง
- acquire_
cli_ slot - Acquires a concurrency slot from the
max_concurrency-position semaphore.