An util for controlling concurrency (lock / unlock) forcing sequential access
to some region of the code
Example:
// Waits for the lock to be free and returns the releaser function
const release = await mutex.acquire()
try {
// Execute the concurrent safe code here
} finally {
// Release the lock.
// Ensures that the lock is always released, even if there are errors
release()
}
An util for controlling concurrency (lock / unlock) forcing sequential access to some region of the code
Example:
// Waits for the lock to be free and returns the releaser function const release = await mutex.acquire()
try { // Execute the concurrent safe code here } finally { // Release the lock. // Ensures that the lock is always released, even if there are errors release() }