mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 15:54:09 +02:00
Initial commit for converting workerScripts pool to Map data structure
This commit is contained in:
@@ -80,6 +80,12 @@ export class WorkerScript {
|
||||
*/
|
||||
output: string = "";
|
||||
|
||||
/**
|
||||
* Process ID. Must be an integer. Used for efficient script
|
||||
* killing and removal.
|
||||
*/
|
||||
pid: number;
|
||||
|
||||
/**
|
||||
* Script's Static RAM usage. Equivalent to underlying script's RAM usage
|
||||
*/
|
||||
@@ -100,10 +106,17 @@ export class WorkerScript {
|
||||
*/
|
||||
serverIp: string;
|
||||
|
||||
constructor(runningScriptObj: RunningScript, nsFuncsGenerator?: (ws: WorkerScript) => object) {
|
||||
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => object) {
|
||||
this.name = runningScriptObj.filename;
|
||||
this.serverIp = runningScriptObj.server;
|
||||
|
||||
const sanitizedPid = Math.round(pid);
|
||||
if (typeof sanitizedPid !== "number" || isNaN(sanitizedPid)) {
|
||||
throw new Error(`Invalid PID when constructing WorkerScript: ${pid}`);
|
||||
}
|
||||
this.pid = sanitizedPid;
|
||||
runningScriptObj.pid = sanitizedPid;
|
||||
|
||||
// Get the underlying script's code
|
||||
const server = AllServers[this.serverIp];
|
||||
if (server == null) {
|
||||
|
||||
Reference in New Issue
Block a user