- Support priority queueing for mutexes and semaphores. A huge "thank you" goes to @dmurvihill who added this feature.
- Update dependencies.
- Expand documentation and fix a few errors.
- Clear timeout after acquiring a lock in
withTimeout
. - Thanks to AkatQuas and aryzing for their contributions.
- Update dependencies.
This is a full rewrite of the core implementation.
- Allow negative values for semaphores.
- Allow weights for
semaphore.acquire
andsemaphore.runExclusive
. A waiter will be dispatched once the value of the semaphore is greater or equal to its weight. - Add
semaphore.getValue
andsemaphore.setValue
. - Allow weights for
semaphore.waitForUnlock
. The promise will only resolve once the value of the semaphore is greater or equal to its weight. - Only resolve
waitForUnlock
once no waiters remain (fixes #52). waitForUnlock
times out if thewithTimeout
decorator is used.
- Add
waitForUnlock
for waiting until a mutex/semaphore is free for locking, thanks to Jason Gore.
withTimeout
: make Jest happy and cancel timer when the mutex is acquired. Thanks to cantoine for the PR.
-
Deprecate
Mutex::release
/Semaphore::release
and remove them from the documentation. The methods are still available in 0.3.x, but will be removed in 0.4.0.I don't like breaking existing APIs, but using those methods is inherently dangerous as they can accidentally release locks acquired in a completely different place. Furthermore, they are mostly useless for semaphores. I consider adding them an unfortunate mistake on my end.
A safe alternative is the usage of
runExclusive
which allows to execute blocks exclusively and automatically manages acquiring and releasing the mutex or semaphore. -
Add
Mutex::cancel
/Semaphore::cancel
for rejecting all currently pending locks. -
Add
tryAcquire
decorator for lock-or-fail semantics.
- Fix a nasty bug related to
consecutive calls to
Mutex::release
.
- Nothing new thanks to NPM. Go away. Install 0.2.6.
- Calling Semaphore::release on a semaphore with concurrency > 1 will not work as expected; throw an exception in this case
- Make the warning on using Semaphore::release and Mutex::release more prominent
- Add alternate Semaphore::release and Mutex::release API
- Work around build warnings with react native (and probably other bundlers)
- Improve compatibility with older versions of node 13, thanks to @josemiguelmelo
- Remove sourcemaps
- Add a
Semaphore
, reimplementMutex
on top of it - Add a
withTimeout
decorator that limits the time the program waits for the mutex or semaphore to become available - Support native ES6 imports on Node >= 12
- Provide an ES6 module entrypoint for ES6 aware bundlers
- Dependency bump
- Switch from TSlint to ESlint
- Enable code coverage in tests
- Documentation updates (thanks to hmil and 0xflotus)
- Update build dependencies
- Move deps to devDependencies (thanks to Meirion Hughes for the PR)
- Upgrade deps
- Move to yarn
- Add tslint
- Switch tests to use ES6
- Add isLocked()
- Fix documentation for
acquire
- Initial release