@sz-md/mutex
v0.5.0
Published
```javascript const mutex = await Mutex.create(options)
Downloads
4
Readme
@sz-md/mutex
const mutex = await Mutex.create(options)
const release = await mutex.acquire()
/* Critical section */
release()
Where options
is an object:
{
_maxQueueLength: 100 // maximum amount of waiters
}
A waiter
is defined as:
The piece of code waiting for the Promise returned by acquire()
to resolve.
API:
mutex.acquire()
mutex.tryAcquire() // returns release() function or NULL
mutex.isLocked() // returns true or false