summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-03-07 18:51:19 -0700
committerGitHub <noreply@github.com>2024-03-07 18:51:19 -0700
commit3745556ccdaa14ac7a9e0849b743669aee124cb3 (patch)
treec97367a326a6de72ada2dc20fe72c2e3b7629b75 /ext/node/polyfills
parent2dfc0aca7c6a04d54fe6f9a73be70fc4c591d552 (diff)
feat(ext/node): ref/unref on workers (#22778)
Implements ref/unref on worker to fix part of #22629
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/worker_threads.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts
index 785bf021d..1efada056 100644
--- a/ext/node/polyfills/worker_threads.ts
+++ b/ext/node/polyfills/worker_threads.ts
@@ -12,6 +12,7 @@ import { notImplemented } from "ext:deno_node/_utils.ts";
import { EventEmitter, once } from "node:events";
import { BroadcastChannel } from "ext:deno_broadcast_channel/01_broadcast_channel.js";
import { MessageChannel, MessagePort } from "ext:deno_web/13_message_port.js";
+import { refWorker, unrefWorker } from "ext:runtime/11_workers.js";
let environmentData = new Map();
let threads = 0;
@@ -170,6 +171,14 @@ class _Worker extends EventEmitter {
this.emit("exit", 0);
}
+ ref() {
+ refWorker(this[kHandle]);
+ }
+
+ unref() {
+ unrefWorker(this[kHandle]);
+ }
+
readonly getHeapSnapshot = () =>
notImplemented("Worker.prototype.getHeapSnapshot");
// fake performance