2.2.0 (2024-06-17)
-
Adds the static
ByteLength
class property, which represents the amount of memory in bytes required by the class.new Mutex(new SharedArrayBuffer(Mutex.ByteLength));
Updated classes include:
- ConditionVariable
- CountingSemaphore
- Latch
- Mutex
- OnceFlag
- RecursiveMutex
- SharedMutex
- SharedTimedMutex
- TimedMutex
-
Adds
bitOffset
validation toOnceFlag
. Invalid values now throw aRangeError
(e.g. when < 0 or >= 32).
2.1.0 (2024-06-13)
Introduces synchronous versions of methods.
-
Sync methods use Atomics.wait, which may not be allowed on the main thread in a browser environment. In these cases, their existing async versions (e.g.
lockSync
->lock
) should be used. -
Interfaces:
- SyncBasicLockable
- SyncLockable
- SyncTimedLockable
-
Classes:
Mutex
extendsSyncLockable
.RecursiveMutex
extendsSyncLockable
.RecursiveTimedMutex
extendsSyncTimedLockable
.TimedMutex
extendsSyncTimedLockable
.UniqueLock
extendsSyncTimedLockable
.
-
Utilities:
- lockGuardSync
- Update dev dependencies
- Add support for JSR:
jsr add @rojas/semafy
2.0.7 (2024-05-15)
-
Classes
MultiLock
for managing multiple locks as one.
-
Utilities
lock()
function for joint locking of multiple locks.
- Fix bug in
tryLock()
utility function. Error was not being re-thrown if it occurred on the first lock.
2.0.6 (2024-05-13)
-
Classes
- Latch
- UniqueLock
- OnceFlag
-
Utilities
- callOnce()
CountingSemaphore
constructor now alternatively accepts an initial value.- The maximum value for
RecursiveMutex
has changed.- Before: Number.MAX_SAFE_INTEGER
- After: (2**31) - 1
CountingSemaphore.MAX
andRecursiveMutex.MAX
constants have been renamed to.Max
.
2.0.5 (2024-05-12)
-
Utilities
tryLock
function for attempted joint locking of multiple locks.
-
Errors
MultiLockError
class to collect and surface errors attempting to lock multiple locks.MultiUnlockError
class to collect and surface errors attempting to unlock multiple locks.
SharedMutex.tryLock
andSharedMutex.tryLockShared
are now non-blocking.
2.0.4 (2024-05-10)
- Fix bug in
lockGuard
. Mutex unlock was not properly awaited on for mutexes with async unlocking.
2.0.3 (2024-05-10)
- Classes
- SharedTimedMutex
2.0.2 (2024-05-10)
-
Interfaces:
- BasicLockable
- Lockable
- SharedLockable
- SharedResource
- SharedTimedLockable
- TimedLockable
-
Classes
- RecursiveTimedMutex
- SharedLock
- TimedMutex
-
Utilities
- lockGuard
Until v2.1.0, breaking changes may be released in patched or minor versions. These will be always be highlighted in the release notes / changelog.
-
Remove .request, .requestFor, .requestShared and .requestUntil methods.
- .request should be replaced by lockGuard.
- .requestShared should be replaced by wrapping the shared mutex in a shared lock and then using lockGuard.
- There are no replacements for .requestFor and .requestUntil at this time.
-
Rename classes
- Mutex -> TimedMutex
- Semaphore -> CountingSemaphore
- MutexError -> LockError
- MutexOwnershipError -> OwnershipError
- MutexRelockError -> RelockError
2.0.1 (2024-05-09)
- Classes
- RecursiveMutex
Given the very brief period since the previous version, this will be released as a patch, despite breaking changes.
- Removed ability to instantiate classes with Int32Array.
- Replace .handle getter with .buffer and .byteOffset getters
- tryLock methods now return false instead of throwing an error if lock already owned.
2.0.0 (2024-05-09)
-
Types
- CVStatus
-
Classes
- ConditionVariable
- SharedMutex
-
Errors
- MutexError
- MutexOwnershipError
- MutexRelockError
- TimeoutError
- Mutex
- Semaphore
Everything. This release is a complete library rewrite from scratch.