Repository navigation
README: Worker (Worker step 5) - #84
Merged
Merged
Conversation
A Worker<In, Out> entry after Thread: the API as MDN's Worker and DedicatedWorkerGlobalScope, what differs here (a function, not a script URL; self a parameter; receive / dispatch / join instead of an event loop; terminate waits for a running handler), errors to onerror, messages handed over rather than copied, join or terminate every worker, and the two -mm=own limits on handlers. The example prints "squared: 1", "squared: 4", "squared: 9" under gc, rc, none and own. docs/worker-design.md marks step 5 done and the design built. The CI matrix needed no change: tests.ps1 / tests.sh run every test, and CI on main ran the worker tests on Windows and Ubuntu under every model, release and debug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Step 5 of
docs/worker-design.md, the last one: aWorker<In, Out>section in the README, right afterThread.It covers:
new Worker(body, name?);selfas aWorkerScope(postMessage,onmessage,close(),name); and on the creating sidepostMessage,onmessageandonerror, withMessageEventandErrorEvent.selfis a parameter, not a global;receive(),dispatch()orjoin();terminate()waits for a handler that's already running instead of killing it.JSON.stringifygives a copy);bodyends it;onerrorset, errors are written to stderr.-mm=ownlimits on handlers:onmessagekeeps its state in aShared<T>;bodycaptures anything from the creating thread, a worker handler can use that state or post withself, not both.gc,rc,noneandown. It printssquared: 1,squared: 4,squared: 9each time, as the README says.docs/worker-design.mdnow marks step 5 done and the design built.CI
The CI matrix needed no change, because
tests.ps1andtests.shrun every file intests/. CI onmainhas already run the worker tests on Windows and Ubuntu under every memory model, release and debug, and they passed. That covers the debug configuration, which couldn't be built locally.🤖 Generated with Claude Code