Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs(shared): changeset + README for try* lock variants

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+31
+23
.changeset/try-lock-variants.md
··· 1 + --- 2 + 'moroutine': minor 3 + --- 4 + 5 + Synchronous `try*` variants for shared locks 6 + 7 + **New methods on `Mutex` and `RwLock`**: 8 + 9 + ```ts 10 + // Non-blocking, single-attempt acquisition. 11 + // Returns a disposable guard on success, `null` on contention. 12 + mutex.tryLock(); // MutexGuard | null 13 + rwlock.tryReadLock(); // ReadGuard | null 14 + rwlock.tryWriteLock(); // WriteGuard | null 15 + ``` 16 + 17 + Each makes a single atomic CAS attempt — no waiting, no retry. Composes with `using` since `null` skips dispose registration: 18 + 19 + ```ts 20 + using guard = mu.tryLock(); 21 + if (!guard) return; // held elsewhere, nothing to dispose 22 + // ...critical section; auto-unlock on scope exit 23 + ```
+8
README.md
··· 310 310 // or manually: 311 311 await mu.lock(); 312 312 mu.unlock(); 313 + 314 + // Non-blocking attempt — returns null if held elsewhere. 315 + using guard = mu.tryLock(); 316 + if (!guard) return; 313 317 ``` 314 318 315 319 #### RwLock ··· 319 323 320 324 using guard = await rw.readLock(); // multiple readers OK 321 325 using guard = await rw.writeLock(); // exclusive access 326 + 327 + // Non-blocking variants — return null if unavailable. 328 + using r = rw.tryReadLock(); // null if write-locked 329 + using w = rw.tryWriteLock(); // null if any lock is held 322 330 ``` 323 331 324 332 ### Using with Workers