ArrayLock class
An isolate-local lock backed by an in-memory ArrayStore.
The lock state is lost when the store is discarded and is not shared with other isolates or processes. Use this implementation for tests and single-isolate applications, not for coordinating multiple workers.
Constructors
- ArrayLock(ArrayStore store, String name, int seconds, [String? owner])
-
Creates a lock with the given
store,name, and lease duration.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The backend key or name used to identify the lock.
finalinherited
- ownerId → String
-
The cooperative owner identifier used for release checks.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seconds → int
-
The requested lease duration in seconds.
finalinherited
- sleepMilliseconds ↔ int
-
The delay in milliseconds between block acquisition attempts.
getter/setter pairinherited
- store → ArrayStore
-
The underlying array store used for locking.
final
Methods
-
acquire(
) → Future< bool> -
Acquires the lock if it is not already held by another owner.
override
-
betweenBlockedAttemptsSleepFor(
int milliseconds) → void -
Sets the delay between blocked acquisition attempts.
inherited
-
block(
int seconds, [Function? callback]) → Future -
Polls until the lock is acquired or the timeout is reached.
override
-
forceRelease(
) → void - Removes the lock entry regardless of ownership.
-
get(
[Function? callback]) → Future -
Acquires the lock and optionally executes a
callbackwhile holding it.override -
getCurrentOwner(
) → Future< String?> -
Gets the recorded owner of the lock.
override
-
isOwnedByCurrentProcess(
) → Future< bool> -
Checks whether the recorded owner matches this lock instance.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
owner(
) → String -
Returns this lock instance's owner identifier.
inherited
-
release(
) → Future< bool> -
Releases the lock if its recorded owner matches this lock instance.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited