Table of Contents

Class StoreFileLock

Namespace
Foundation.Data.Doublets.Cli
Assembly
Foundation.Data.Doublets.Cli.dll

The operating system lock --lock flock takes on <db>.lock (issue #194), the same lock the Rust and JavaScript clink take, so that every implementation excludes the others: flock(2) on Unix and LockFileEx over the whole file (offset 0, length u32::MAX twice) on Windows. The system releases it when the holder exits.

public sealed class StoreFileLock : IDisposable
Inheritance
StoreFileLock
Implements
Inherited Members

Remarks

On Unix the runtime takes the flock itself when a file is opened: None is LOCK_EX, anything else LOCK_SH (see LinksFileLock). On Windows FileShare only sets share modes, which the Rust and JavaScript clink do not see, so the lock is taken with LockFileEx on a handle that shares everything.

Properties

Mode

Whether the lock is shared or exclusive.

public LockMode Mode { get; }

Property Value

LockMode

Path

The lock file.

public string Path { get; }

Property Value

string

Methods

Dispose()

Releases the lock.

public void Dispose()

TryAcquire(string, LockMode)

Tries the lock once; null while another holder has a conflicting one.

public static StoreFileLock? TryAcquire(string lockPath, LockMode mode)

Parameters

lockPath string
mode LockMode

Returns

StoreFileLock