pub struct GcLock { /* private fields */ }Expand description
Repository-wide maintenance lock, compatible with Git’s gc.pid.
The lock file holds "<pid> <hostname>" and is removed when this value is dropped. An
existing gc.pid counts as held while it is younger than 12 hours and either names another
host or a process on this host that is still running; older or dead entries are taken over.
Implementations§
Source§impl GcLock
impl GcLock
Sourcepub fn try_acquire(repo: &Repository, now_unix: i64) -> Result<GcLockAttempt>
pub fn try_acquire(repo: &Repository, now_unix: i64) -> Result<GcLockAttempt>
Try to take the gc.pid lock in the repository’s common directory without waiting.
now_unix is the wall clock used to decide whether an existing gc.pid is stale.
§Errors
I/O failures while creating, writing or renaming the lock file.
Sourcepub fn current_holder(repo: &Repository, now_unix: i64) -> Option<GcLockHolder>
pub fn current_holder(repo: &Repository, now_unix: i64) -> Option<GcLockHolder>
The maintenance run currently holding gc.pid, without taking the lock.
Uses the same staleness rules as Self::try_acquire, so None means an attempt would
most likely succeed. Lets a caller avoid starting a process that would only find the
lock held.