OkfBundleLock class final

Coordinates bundle operations within one isolate and across processes.

An isolate-local FIFO queue prevents local operations from interleaving. Processes coordinate through an advisory lock on <root>/.okf.lock: read takes a shared lock and write takes an exclusive lock. Keeping the file inside the bundle gives every process the same path and does not require write access to the bundle's parent directory.

The loader, writer and change applier already take these claims; callers use them directly to run their own reads or writes under the same lock. Claims nest: an action may run further operations on the same bundle, and a shared claim cannot be upgraded to an exclusive one. A claim is carried by the action's zone, so await every bundle operation inside the action: work that outlives it, such as an unawaited future, a timer or a stream listener, still counts as holding the claim, so it skips the queue while no lock is held.

On POSIX the lock is an fcntl record lock, which belongs to the process rather than to an isolate. Isolates in one process do not exclude each other, and closing any descriptor of the lock file releases every claim the process holds on it, so a read finishing in one isolate can silently drop a write's lock in another. Run every operation on a bundle in one isolate per process.

A missing or invalid root is left for the operation itself to report.

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

read<T>(String rootPath, Future<T> action()) → Future<T>
Runs action with a shared claim on the bundle at rootPath.
write<T>(String rootPath, Future<T> action()) → Future<T>
Runs action with an exclusive claim on the bundle at rootPath.