feat(ext/node): ref/unref on workers (#22778)

Implements ref/unref on worker to fix part of #22629
This commit is contained in:
Matt Mastracci 2024-03-07 18:51:19 -07:00 committed by GitHub
parent 2dfc0aca7c
commit 3745556ccd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 80 additions and 5 deletions

View file

@ -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