pub struct LoopLock;Expand description
The loop lock mechanism.
Uses flock() to provide advisory locking on .ralph/loop.lock.
The lock is automatically released when the process exits (even on crash).
Implementations§
Source§impl LoopLock
impl LoopLock
Sourcepub const LOCK_FILE: &'static str = ".ralph/loop.lock"
pub const LOCK_FILE: &'static str = ".ralph/loop.lock"
The relative path to the lock file within the workspace.
Sourcepub fn try_acquire(
workspace_root: impl AsRef<Path>,
prompt: &str,
) -> Result<LockGuard, LockError>
pub fn try_acquire( workspace_root: impl AsRef<Path>, prompt: &str, ) -> Result<LockGuard, LockError>
Try to acquire the loop lock (non-blocking).
§Arguments
workspace_root- Root directory of the workspaceprompt- The prompt/task being executed (stored in lock metadata)
§Returns
Ok(LockGuard)- Lock acquired successfullyErr(LockError::AlreadyLocked(metadata))- Another process holds the lockErr(LockError::Io(_))- IO error
Sourcepub fn acquire_blocking(
workspace_root: impl AsRef<Path>,
prompt: &str,
) -> Result<LockGuard, LockError>
pub fn acquire_blocking( workspace_root: impl AsRef<Path>, prompt: &str, ) -> Result<LockGuard, LockError>
Acquire the loop lock, blocking until available.
This should be used with the --exclusive flag to wait for the
primary loop slot instead of spawning into a worktree.
§Arguments
workspace_root- Root directory of the workspaceprompt- The prompt/task being executed
§Returns
Ok(LockGuard)- Lock acquired successfullyErr(LockError::Io(_))- IO error
Sourcepub fn read_existing(
workspace_root: impl AsRef<Path>,
) -> Result<Option<LockMetadata>, LockError>
pub fn read_existing( workspace_root: impl AsRef<Path>, ) -> Result<Option<LockMetadata>, LockError>
Read the metadata from an existing lock file.
This can be used to check who holds the lock without acquiring it.
Auto Trait Implementations§
impl Freeze for LoopLock
impl RefUnwindSafe for LoopLock
impl Send for LoopLock
impl Sync for LoopLock
impl Unpin for LoopLock
impl UnsafeUnpin for LoopLock
impl UnwindSafe for LoopLock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more