Skip to content

worker: add ability to unshift message from MessagePort

worker: move receiving_messages_ field to MessagePort (landed as part of #27705)

This is a property of the native object associated with the MessagePort, not something that should be set on the conceptual MessagePort that may be transferred around.

(This is just cleanup that’s not directly related to the next commit except for merge conflicts.)

worker: add ability to unshift message from MessagePort

In combination with Atomics, this makes it possible to implement generic synchronous functionality, e.g. importScript(), in Workers purely by communicating with other threads.

This is a continuation of https://github.com/nodejs/node/pull/26686, where a preference for a solution was voiced that allowed reading individual messages, rather than emitting all messages through events.

(/cc @devsnek, @BridgeAR, @nodejs/workers)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading