Skip to main content

Lock

Struct Lock 

Source
pub struct Lock { /* private fields */ }
Expand description

Cross-process exclusive bench lock. Drop releases.

Implementations§

Source§

impl Lock

Source

pub fn acquire(cfg: AcquireConfig) -> Result<Self>

Block until the lock is acquired (subject to cfg.timeout). Prints periodic “waiting on …” messages to stderr while blocked, each describing the current holder and ETA.

Source

pub fn try_acquire( cfg: AcquireConfig, ) -> Result<Result<Self, Option<HolderInfo>>>

Try to acquire without blocking. On success, returns Ok(Lock). If another process holds it, returns Ok(Err(Some(info))) with the holder’s record. Ok(Err(None)) means the lock was held but the holder file was unreadable.

Source

pub fn peek(path: &Path) -> Result<Option<HolderInfo>>

Read the current holder’s record without taking the lock. Returns Ok(None) if the file is absent, empty, or mid-rewrite — the file format is self-validating with an eof=1 sentinel.

Source

pub fn default_path() -> PathBuf

Default lock path for the host. Use this if you want to construct a custom config that still rendezvouses on the system-wide path.

Source

pub fn update_benchmark(&self, benchmark: &str)

Update the benchmark= field in the holder file. Call this from the engine as it transitions between bench groups.

Source

pub fn update_eta(&self, eta: SystemTime)

Set a new ETA. Useful once the engine has measured a few groups and can extrapolate completion.

Source

pub fn info(&self) -> Option<HolderInfo>

Snapshot of the current in-memory holder record.

Source

pub fn path(&self) -> &Path

Filesystem path of the lock file.

Trait Implementations§

Source§

impl Drop for Lock

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.