This PR adds a new API to worker_threads called postMessageToThread that allow to send arbitrary messages to any worker thread just identifying it by its threadId.
The recipient thread must have a listener on the new workerMessage event emitted on process otherwise the postMessageToThread will throw an exception.
In order not to have any thread block, the call is async to use Atomics.waitAsync.
Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
author ready
PRs that have at least one approval, no outstanding review comments, and a CI started.
lib / src
Issues and PRs related to general changes in the lib or src directory.
needs-ci
PRs that need a full CI run.
process
Issues and PRs related to the process subsystem.
semver-minor
PRs that contain new features and should be released in the next minor version.
worker
Issues and PRs related to Worker support.
Projects
None yet
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
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.
This PR is a total rethinking of #53488.
This PR adds a new API to worker_threads called postMessageToThread that allow to send arbitrary messages to any worker thread just identifying it by its threadId.
The recipient thread must have a listener on the new workerMessage event emitted on process otherwise the postMessageToThread will throw an exception.
In order not to have any thread block, the call is async to use Atomics.waitAsync.