LockManager class

File-based implementation of ILockManager.

Lock files are stored in a parallel directory structure:

  • Data: ./WorkDB/collection/item
  • Lock: ./WorkDBLocks/collection/item.lock

Usage

final lockManager = LockManager(fileSystem);

if (await lockManager.tryAcquire('users/user-1')) {
  try {
    // perform operation
  } finally {
    await lockManager.release('users/user-1');
  }
}
Implemented types

Constructors

LockManager(IWorkFileSystem _fs, [int _waitingMs = 0])
Creates a new LockManager.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearAllLocks() → Future<void>
Clears all locks.
override
isLocked(String documentPath) → Future<bool>
Checks if a document is currently locked.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release(String documentPath) → Future<void>
Releases the lock on the document.
override
toString() → String
A string representation of this object.
inherited
tryAcquire(String documentPath) → Future<bool>
Attempts to acquire a lock on the document.
override
tryAcquireThrow(String documentPath) → Future<void>
Attempts to acquire a lock, throwing an exception if already locked.

Operators

operator ==(Object other) → bool
The equality operator.
inherited