Skip to main content

try_with_metadata_file_lock

Function try_with_metadata_file_lock 

Source
pub async fn try_with_metadata_file_lock<T, F, Fut>(
    metadata_path: &Path,
    cycle: F,
) -> StorageResult<T>
where F: FnOnce() -> Fut, Fut: Future<Output = StorageResult<T>>,
Expand description

Fail-fast counterpart of with_metadata_file_lock (#105): the lock file is resolved through lock_file_for_metadata and acquired with [FileLock::try_acquire] — on cross-process contention the call returns StorageError::LockWouldBlock naming the derived lock file without parking; uncontended, the file lock is held across the whole awaited commit-actor cycle exactly as in with_metadata_file_lock (cross-process exclusion and in-process actor serialization).

The try applies to the flock only: once acquired, the awaited commit-actor cycle still serializes against in-process cycles as usual. Advisory, cooperating-writers-only, rendezvous-point semantics are identical to the blocking form; off unix this fails with StorageError::UnsupportedFormat.