Lock class abstract

Object providing the implicit lock.

A Lock can be reentrant (in this case it will use a Zone).

non-reentrant lock is used like an aync executor with a capacity of 1.

if timeout is not null, it will timeout after the specified duration.

Implementers
Available extensions

Constructors

Lock.new({bool reentrant = false})
Creates a Lock object.
factory

Properties

canLock bool
It returns true if the lock can be locked. For basic lock (reentrant or not), it is when the lock is not locked.
no setter
hashCode int
The hash code for this object.
no setterinherited
inLock bool
for reentrant, test whether we are currently in the synchronized section. for non reentrant, it returns the locked status.
no setter
locked bool
returns true if the lock is currently locked.
no setter
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
synchronized<T>(FutureOr<T> computation(), {Duration? timeout}) Future<T>
Executes computation when lock is available.
synchronizedSync<T>(T computation(), {Duration? timeout}) FutureOr<T>

Available on Lock, provided by the TekartikLockExtension extension

Executes a synchronous computation. If the lock is not locked, it will run the computation immediately and return its value synchronously.
toString() String
A string representation of this object.
inherited

Operators

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