mirror of
https://github.com/denoland/deno.git
synced 2025-08-31 15:57:53 +00:00
feat(ext/node): ref/unref on workers (#22778)
Implements ref/unref on worker to fix part of #22629
This commit is contained in:
parent
2dfc0aca7c
commit
3745556ccd
3 changed files with 80 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue