summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/worker_threads.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/worker_threads.ts')
-rw-r--r--ext/node/polyfills/worker_threads.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts
index 3c8c9d443..323095206 100644
--- a/ext/node/polyfills/worker_threads.ts
+++ b/ext/node/polyfills/worker_threads.ts
@@ -18,7 +18,9 @@ import {
MessagePortIdSymbol,
MessagePortPrototype,
nodeWorkerThreadCloseCb,
+ refMessagePort,
serializeJsMessageData,
+ unrefPollForMessages,
} from "ext:deno_web/13_message_port.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { notImplemented } from "ext:deno_node/_utils.ts";
@@ -398,6 +400,12 @@ internals.__initWorkerThreads = (
parentPort.addEventListener("offline", () => {
parentPort.emit("close");
});
+ parentPort.unref = () => {
+ parentPort[unrefPollForMessages] = true;
+ };
+ parentPort.ref = () => {
+ parentPort[unrefPollForMessages] = false;
+ };
}
};
@@ -467,6 +475,12 @@ function webMessagePortToNodeMessagePort(port: MessagePort) {
port[nodeWorkerThreadCloseCb] = () => {
port.dispatchEvent(new Event("close"));
};
+ port.unref = () => {
+ port[refMessagePort](false);
+ };
+ port.ref = () => {
+ port[refMessagePort](true);
+ };
return port;
}