implement node:cluster (#11492)

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: nektro <nektro@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
This commit is contained in:
Meghan Denny
2024-08-18 00:12:42 -07:00
committed by GitHub
parent a53db001db
commit fd75ca7585
93 changed files with 5258 additions and 297 deletions

View File

@@ -0,0 +1,39 @@
const std = @import("std");
const bun = @import("root").bun;
const Environment = bun.Environment;
const JSC = bun.JSC;
const string = bun.string;
const Output = bun.Output;
const ZigString = JSC.ZigString;
const uv = bun.windows.libuv;
pub fn getBunServerAllClosedPromise(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
const arguments = callframe.arguments(1).slice();
if (arguments.len < 1) {
globalThis.throwNotEnoughArguments("getBunServerAllClosePromise", 1, arguments.len);
return .zero;
}
const value = arguments[0];
inline for ([_]type{
JSC.API.HTTPServer,
JSC.API.HTTPSServer,
JSC.API.DebugHTTPServer,
JSC.API.DebugHTTPSServer,
}) |Server| {
if (value.as(Server)) |server| {
if (server.listener == null and server.pending_requests == 0) {
return JSC.JSPromise.resolvedPromise(globalThis, .undefined).asValue(globalThis);
}
const prom = &server.all_closed_promise;
if (prom.strong.has()) {
return prom.value();
}
prom.* = JSC.JSPromise.Strong.init(globalThis);
return prom.value();
}
}
return globalThis.throwInvalidArgumentTypeValue("server", "bun.Server", value);
}