/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ext/node/polyfills/internal/cluster/utils.ts
61 строка
1 KB
Nathan Whitaker
perf: lazy-load more modules in the snapshot (#34061)
19 май 2026, 02:37
Не верифицирован
19 май 2026, 02:37
eb4061f
Код
Авторство
О чём код?
// Copyright 2018-2026 the Deno authors. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. // Ports lib/internal/cluster/utils.js. // deno-lint-ignore-file no-explicit-any (function () { const { primordials } = __bootstrap; const { ReflectApply, SafeMap } = primordials; const callbacks = new SafeMap(); let seq = 0; function sendHelper( proc: any, message: any, handle: any, cb?: (...args: any[]) => void, ): boolean { if (!proc.connected) { return false; } // Mark message as internal. Mirrors lib/internal/child_process.js prefix. message = { cmd: "NODE_CLUSTER", ...message, seq }; if (typeof cb === "function") { callbacks.set(seq, cb); } seq += 1; return proc.send(message, handle); } // Returns an internalMessage listener that hands off normal messages to the // callback but intercepts and redirects ACK messages. function internal( worker: any, cb: (this: any, message: any, handle?: any) => void, ) { return function onInternalMessage(this: any, message: any, _handle?: any) { if (message.cmd !== "NODE_CLUSTER") { return; } let fn: any = cb; if (message.ack !== undefined) { const callback = callbacks.get(message.ack); if (callback !== undefined) { fn = callback; callbacks.delete(message.ack); } } ReflectApply(fn, worker, arguments); }; } return { sendHelper, internal }; })();