Safely using a mutex by always releasing
// Ensure you import LockPowers import { LockPowers } from "@andi/powers"; const mutex = await LockPowers.createMutex("my-lock"); try { // critical code } finally { await mutex.release(); }
Can optionally handle errors with a catch block, but be sure to always call .release()
.release()
identifier helpful for debugging
Attempt to acquire lock. @throws LockAcquireTimeoutError if lock is not acquired within the configured lockTimeout
LockAcquireTimeoutError
lockTimeout
Release lock.
Method to acquire lock. Will not throw an error if acquireTimeout occurs.
Generated using TypeDoc
Safely using a mutex by always releasing
// Ensure you import LockPowers import { LockPowers } from "@andi/powers"; const mutex = await LockPowers.createMutex("my-lock"); try { // critical code } finally { await mutex.release(); }
Can optionally handle errors with a catch block, but be sure to always call
.release()