async-mutex
Advanced tools
Changelog
0.5.0 - 2024/03/11
Changelog
0.4.1 - 2024/01/17
withTimeout
.Changelog
0.4.0 - 2022/09/02
This is a full rewrite of the core implementation.
semaphore.acquire
and semaphore.runExclusive
.
A waiter will be dispatched once the value of the semaphore is greater or
equal to its weight.semaphore.getValue
and semaphore.setValue
.semaphore.waitForUnlock
. The promise will only resolve
once the value of the semaphore is greater or equal to its weight.waitForUnlock
once no waiters remain (fixes #52).waitForUnlock
times out if the withTimeout
decorator is used.Changelog
0.3.2 - 2021/08/30
waitForUnlock
for waiting until a mutex/semaphore is free for locking,
thanks to Jason Gore.Changelog
0.3.1 - 2021/02/22
withTimeout
: make Jest happy and cancel timer when the mutex is acquired.
Thanks to cantoine for the PR.Changelog
0.3.0 - 2021/02/05
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.
Changelog
0.2.5 - 2020/11/28
Changelog
0.2.4 - 2020/07/09
Changelog
0.2.3 - 2020/06/18