pub struct Lock { /* private fields */ }Expand description
A held advisory lock. Dropping it releases the lock.
Implementations§
Source§impl Lock
impl Lock
Sourcepub fn acquire(
path: &Utf8Path,
mode: Mode,
purpose: &str,
) -> Result<Self, AppError>
pub fn acquire( path: &Utf8Path, mode: Mode, purpose: &str, ) -> Result<Self, AppError>
Take the lock at path, or refuse naming its holder.
§Errors
AppError::Busy when another process holds it, and I/O errors
when the lock file cannot be created.
Sourcepub fn exclusive_waiting(
path: &Utf8Path,
purpose: &str,
budget: Duration,
) -> Result<Self, AppError>
pub fn exclusive_waiting( path: &Utf8Path, purpose: &str, budget: Duration, ) -> Result<Self, AppError>
Take the lock alone, waiting a bounded time for a holder to leave.
For a lock whose critical section is short and whose contention is ordinary rather than exceptional: two operators planning at once should queue, not fail. The bound keeps a dead holder from hanging a command, so a wait that runs out still refuses and names it.
§Errors
AppError::Busy when the wait runs out, and I/O errors when the
lock file cannot be created.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lock
impl RefUnwindSafe for Lock
impl Send for Lock
impl Sync for Lock
impl Unpin for Lock
impl UnsafeUnpin for Lock
impl UnwindSafe for Lock
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