Minimal async mutex for serializing concurrent promise-based operations.
Maintains an internal promise chain that ensures each function passed to
.acquire() runs after the previous one completes, preventing race conditions
when multiple coroutines compete for write access to a shared resource.
Errors in one function do not break the chain — the queue continues processing.
Example
constmutex = newAsyncMutex(); awaitmutex.acquire(async () => { // This block runs serially relative to all other acquire() calls });
Minimal async mutex for serializing concurrent promise-based operations.
Maintains an internal promise chain that ensures each function passed to
.acquire()runs after the previous one completes, preventing race conditions when multiple coroutines compete for write access to a shared resource.Errors in one function do not break the chain — the queue continues processing.
Example