FileMutex class final

A Mutex implemented with RandomAccessFile.lock.

This mutex is safe to use across processes, but not for multiple isolates within a single process. It is designed to be used as a global singleton active for the entire lifecycle of a process.

Note that file locking has platform-specific behavior, which impacts this mutex implementation. On POSIX systems for example, this uses advisory locks, which are per process. So multiple isolates using a file mutex in the same process would be able to access the critical section concurrently.

Implemented types

Constructors

FileMutex(Directory _directory, String _lockName)
Creates a named mutex in a directory.

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

close() → Future<void>
Closes the file descriptor or handle used by this mutex.
lock<T>(Future<T> callback(), {Future<void>? abortTrigger}) → Future<T>
Runs callback in a critical section.
override
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