Releases: havelessbemore/semafy
v2.2.0
What's New
-
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).
Full Changelog: v2.1.0...v2.2.0
v2.1.0
What's New
Introduces synchronous method versions.
-
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
now extendsSyncLockable
.RecursiveMutex
now extendsSyncLockable
.RecursiveTimedMutex
now extendsSyncTimedLockable
.TimedMutex
now extendsSyncTimedLockable
.UniqueLock
now extendsSyncTimedLockable
.
-
Utilities:
- lockGuardSync
Misc
-
Add support for JSR:
jsr add @rojas/semafy
-
Update dev dependencies:
- npm: bump typedoc-plugin-markdown from 4.0.1 to 4.0.2 by @dependabot in #19
- npm: bump esbuild from 0.21.2 to 0.21.3 by @dependabot in #18
- npm: bump typescript-eslint from 7.9.0 to 7.10.0 by @dependabot in #17
- npm: bump rollup-plugin-dts from 6.1.0 to 6.1.1 by @dependabot in #16
- npm: bump typedoc-plugin-markdown from 4.0.2 to 4.0.3 by @dependabot in #24
- npm: bump rollup from 4.17.2 to 4.18.0 by @dependabot in #23
- npm: bump esbuild from 0.21.3 to 0.21.4 by @dependabot in #22
- npm: bump ts-jest from 29.1.2 to 29.1.3 by @dependabot in #21
- npm: bump typescript-eslint from 7.10.0 to 7.11.0 by @dependabot in #20
- npm: bump prettier from 3.2.5 to 3.3.0 by @dependabot in #28
- npm: bump typescript-eslint from 7.11.0 to 7.12.0 by @dependabot in #27
- npm: bump ts-jest from 29.1.3 to 29.1.4 by @dependabot in #26
- npm: bump lint-staged from 15.2.2 to 15.2.5 by @dependabot in #25
- npm: bump tslib from 2.6.2 to 2.6.3 by @dependabot in #32
- npm: bump typescript-eslint from 7.12.0 to 7.13.0 by @dependabot in #31
- npm: bump esbuild from 0.21.4 to 0.21.5 by @dependabot in #30
- npm: bump prettier from 3.3.0 to 3.3.2 by @dependabot in #33
New Contributors
- @dependabot made their first contribution in #19
Full Changelog: v2.0.7...v2.1.0
v2.0.7
What's New
-
Classes
MultiLock
for managing multiple locks as one.
-
Utilities
lock()
function for joint locking of multiple locks.
What's Changed
- Fix bug in
tryLock()
utility function. Error was not being re-thrown if it occurred on the first lock.
Full Changelog: v2.0.6...v2.0.7
v2.0.6
What's New
- Adds
Latch
class - Adds
UniqueLock
class - Adds
OnceFlag
class - Adds
callOnce()
function
What's Changed
CountingSemaphore
constructor now alternatively accepts an initial value.- The maximum value for
RecursiveMutex
has changed to (2**31) - 1. It was previously Number.MAX_SAFE_INTEGER.
Breaking Changes
MAX
class constants forCountingSemaphore
andRecursiveMutex
have been renamed toMax
.
Full Changelog: v2.0.5...v2.0.6
v2.0.5
What's New
- Add
tryLock
function for attempted joint locking of multiple locks. - Add
MultiLockError
class to collect and surface errors attempting to lock multiple locks. - Add
MultiUnlockError
class to collect and surface errors attempting to unlock multiple locks.
What's Changed
- Make
tryLock
andtryLockShared
methods non-blocking inSharedMutex
class
Full Changelog: v2.0.4...v2.0.5
v2.0.4
What's Changed
- Fix bug in lockGuard. Mutex unlock was not properly awaited on for mutexes with async unlocks.
Full Changelog: v2.0.3...v2.0.4
v2.0.3
What's New
- Adds SharedTimedMutex class
What's Changed
- Updates README.md
Full Changelog: v2.0.2...v2.0.3
v2.0.2
What's New
-
Interfaces:
- BasicLockable
- Lockable
- SharedLockable
- SharedResource
- SharedTimedLockable
- TimedLockable
-
Classes
- RecursiveTimedMutex
- SharedLock
- TimedMutex
-
Utilities
- lockGuard
Breaking Changes
This patch introduces breaking changes from prior 2.0.x versions. I understand this is not best practices and promise to avoid this from 2.1 onwards.
-
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
Full Changelog: v2.0.1...v2.0.2
v2.0.1
What's Changed
- Added RecursiveMutex class.
- Removed ability to instantiate classes with Int32Array.
- Removed .handle getter, replaced with .buffer and .byteOffset getters
- tryLock methods now return false instead of throwing an error if lock already owned.
Given the very brief period since the previous version, this will be released as a patch, despite breaking changes.
Full Changelog: v2.0.0...v2.1.0