0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/lib/worker_threads.js
Anna Henningsen 76f2168393
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.

PR-URL: https://github.com/nodejs/node/pull/27294
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-05-19 22:01:34 +02:00

29 lines
432 B
JavaScript

'use strict';
const {
isMainThread,
SHARE_ENV,
threadId,
Worker
} = require('internal/worker');
const {
MessagePort,
MessageChannel,
moveMessagePortToContext,
receiveMessageOnPort
} = require('internal/worker/io');
module.exports = {
isMainThread,
MessagePort,
MessageChannel,
moveMessagePortToContext,
receiveMessageOnPort,
threadId,
SHARE_ENV,
Worker,
parentPort: null,
workerData: null,
};