) { if (key === @undefined) return; unref(), send({ act: "close", key }), handles.delete(key), removeIndexesKey(indexesKey, index), key = @undefined; } function getsockname(out) { if (key) ObjectAssign(out, message.sockname); return 0; } let handle = { close, listen, ref, unref }; if (handle.ref(), message.sockname) handle.getsockname = getsockname; handles.set(key, handle), cb(0, handle); } function onconnection(message, handle) { let key = message.key, server = handles.get(key), accepted = server !== @undefined; if (accepted && server[owner_symbol]) { let self = server[owner_symbol]; if (self.maxConnections != null && self._connections >= self.maxConnections) accepted = !1; } if (send({ ack: message.seq, accepted }), accepted) server.onconnection(0, handle); else handle.close(); } function send(message, cb) { return sendHelper(message, null, cb); } Worker.prototype.disconnect = function() { if (this.state !== "disconnecting" && this.state !== "destroying") this.state = "disconnecting", this._disconnect(); return this; }; Worker.prototype._disconnect = function(primaryInitiated) { this.exitedAfterDisconnect = !0; let waitingCount = 1; function checkWaitingCount() { if (waitingCount--, waitingCount === 0) if (primaryInitiated) process.disconnect(); else send({ act: "exitedAfterDisconnect" }, () => process.disconnect()); } handles.forEach((handle) => { if (waitingCount++, handle[owner_symbol]) handle[owner_symbol].close(checkWaitingCount); else handle.close(checkWaitingCount); }), handles.clear(), checkWaitingCount(); }; Worker.prototype.destroy = function() { if (this.state === "destroying") return; if (this.exitedAfterDisconnect = !0, !this.isConnected()) process.exit(0); else this.state = "destroying", send({ act: "exitedAfterDisconnect" }, () => process.disconnect()), process.once("disconnect", () => process.exit(0)); }; return $})