Table of Contents

Class ModelFileLock

Namespace
LMKit.Model
Assembly
LM-Kit.NET.dll

Cross-process guard for materializing one model file on a volume that several processes may share: the first writer holds an exclusive lock file beside the destination while it downloads or extracts, every other process asking for the same file waits on that lock instead of writing concurrently, and on release the waiter finds the finished file and simply uses it. The lock file is opened with DeleteOnClose and no sharing, so it evaporates with its holder: a crashed writer releases waiters through the operating system, never through cleanup code that would have to run. Uncontended acquisition costs one file create/delete.

public static class ModelFileLock
Inheritance
ModelFileLock
Inherited Members

Methods

Acquire(string)

Acquires the materialization lock for one destination file, blocking while another process holds it. Dispose the returned handle after the write attempt (success or failure) so waiters proceed. There is no overall timeout: a large model legitimately transfers for a long time, and a dead holder's handle is closed by the operating system, so waiting cannot deadlock on a dead process.

TryAcquire(string, TimeSpan, out IDisposable)

Acquires the materialization lock for one destination file if it lands within timeout; returns false, with no waiter left behind, when another process still holds it at the deadline. For a caller that must answer rather than wait out a transfer (a delete, a probe): it never sits through a multi-hour pull, and it leaves nothing polling the volume once it has given up. Dispose handle after the write attempt.

Share