class

Lock

@Js
const class Lock : Obj

Lock for synchronization between actors.

methods lock

Acquire the lock

makeReentrant

Construct mutual exclusion lock

tryLock

Acquire the lock if its free and immediately return true

unlock

Release the lock

withLock

Run callback while holding the lock and guarantee its released

lock Void lock()

Acquire the lock; if not available then block forever until its available.

makeReentrant static Lock makeReentrant()

Construct mutual exclusion lock.

tryLock Bool tryLock(Duration? timeout := null)

Acquire the lock if its free and immediately return true. Or if the lock is not available and timeout is null, then immediately return false. If timeout is non-null, then block up to the given timeout waiting for the lock and return true if lock acquired or false on timeout.

unlock Void unlock()

Release the lock. Raise exception if not holding the lock.

withLock Obj? withLock(|This->Obj?| f)

Run callback while holding the lock and guarantee its released. Return the result of thecallback function.

Haxall 4.0.6 ∙ 21-Jul-2026 09:48 EDT