@toolbuilder/semaphore
v1.0.0
Published
Basic semaphore and mutex with both sync and async acquire methods.
Maintainers
Readme
Semaphore and Mutex
This library provides Semaphore and Mutex implementations. You can acquire a lock with either async or sync methods.
Installation
npm install @toolbuilder/semaphoreUse
The API documentation is here
import { Mutex } from '@toolbuilder/semaphore'
const mutex = new Mutex()
const release = await mutex.acquire()
release() // to release muteximport { Mutex, Semaphore } from '@toolbuilder/semaphore'
const semaphore = new Semaphore(5) // max locks that can be acquired
await semaphore.acquire()
semaphore.release() // to release lockContributing
At this point, I have no intention of further changes to the API. Any updates to devDependencies will be infrequent.
Contributions are welcome. Please create a pull request.
Issues
This project uses Github issues.
License
MIT
