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.

chore: version 1.2.0

+33 -33
-32
.changeset/stream-atomics.md
··· 1 - --- 2 - 'moroutine': minor 3 - --- 4 - 5 - Atomics-based backpressure for streams and channels; new `Int32Atomic#waitAsync` / `#notify` 6 - 7 - **New public API on `Int32Atomic`**: 8 - 9 - ```ts 10 - const slot = int32atomic(); 11 - // Park until the slot holds a value other than `expected`, with optional timeout. 12 - await slot.waitAsync(0); // 'ok' | 'not-equal' | 'timed-out' 13 - await slot.waitAsync(0, 100 /*ms*/); 14 - // Wake waiters on this slot. 15 - slot.notify(); // wake all 16 - slot.notify(2); // wake at most 2 17 - ``` 18 - 19 - Matches `Atomics.waitAsync` / `Atomics.notify` semantics; returns `'not-equal'` synchronously (no microtask hop) if the slot already holds something different from `expected`. 20 - 21 - **Streams and channels use atomics for backpressure**: streaming tasks and `channel()` no longer rely on `pause`/`resume` port messages for flow control. Internally, a `SharedArrayBuffer` tracks per-endpoint `inflight` and `state`; the producer parks on `Atomics.waitAsync` when the `highWaterMark` cap is reached and resumes when the consumer drains below it. Behavior-equivalent and much tighter under backpressure (worst-case buffering drops from ~10-20× `highWaterMark` to `highWaterMark + 1-2`). 22 - 23 - **`highWaterMark` option now honored** for both `run(streamTask, { highWaterMark })` and `channel(src, { highWaterMark })`. Previously read and discarded in the streaming path. 24 - 25 - **Significant throughput improvements** on streaming and channel fan-out: 26 - 27 - - Worker → parent stream: ~66K items/s → ~750K items/s (11×) 28 - - Round-trip stream: ~39K items/s → ~425K items/s (11×) 29 - - Channel fan-out at 8 consumers: ~412K items/s → ~546K items/s (+33%) 30 - - Per-task dispatch: ~289K → ~328K (+14%) 31 - 32 - No changes to user-facing API shape beyond the `Int32Atomic` additions.
+32
CHANGELOG.md
··· 1 1 # moroutine 2 2 3 + ## 1.2.0 4 + 5 + ### Minor Changes 6 + 7 + - 24741da: Atomics-based backpressure for streams and channels; new `Int32Atomic#waitAsync` / `#notify` 8 + 9 + **New public API on `Int32Atomic`**: 10 + 11 + ```ts 12 + const slot = int32atomic(); 13 + // Park until the slot holds a value other than `expected`, with optional timeout. 14 + await slot.waitAsync(0); // 'ok' | 'not-equal' | 'timed-out' 15 + await slot.waitAsync(0, 100 /*ms*/); 16 + // Wake waiters on this slot. 17 + slot.notify(); // wake all 18 + slot.notify(2); // wake at most 2 19 + ``` 20 + 21 + Matches `Atomics.waitAsync` / `Atomics.notify` semantics; returns `'not-equal'` synchronously (no microtask hop) if the slot already holds something different from `expected`. 22 + 23 + **Streams and channels use atomics for backpressure**: streaming tasks and `channel()` no longer rely on `pause`/`resume` port messages for flow control. Internally, a `SharedArrayBuffer` tracks per-endpoint `inflight` and `state`; the producer parks on `Atomics.waitAsync` when the `highWaterMark` cap is reached and resumes when the consumer drains below it. Behavior-equivalent and much tighter under backpressure (worst-case buffering drops from ~10-20× `highWaterMark` to `highWaterMark + 1-2`). 24 + 25 + **`highWaterMark` option now honored** for both `run(streamTask, { highWaterMark })` and `channel(src, { highWaterMark })`. Previously read and discarded in the streaming path. 26 + 27 + **Significant throughput improvements** on streaming and channel fan-out: 28 + - Worker → parent stream: ~66K items/s → ~750K items/s (11×) 29 + - Round-trip stream: ~39K items/s → ~425K items/s (11×) 30 + - Channel fan-out at 8 consumers: ~412K items/s → ~546K items/s (+33%) 31 + - Per-task dispatch: ~289K → ~328K (+14%) 32 + 33 + No changes to user-facing API shape beyond the `Int32Atomic` additions. 34 + 3 35 ## 1.1.0 4 36 5 37 ### Minor Changes
+1 -1
package.json
··· 1 1 { 2 2 "name": "moroutine", 3 - "version": "1.1.0", 3 + "version": "1.2.0", 4 4 "repository": { 5 5 "type": "git", 6 6 "url": "git@tangled.org:divy.zone/moroutine"