@shahadul-17/dispatcher
Version:
Defines a mechanism for parallel processing and CPU intensive tasks in Node.js
64 lines • 2.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Process = void 0;
const utilities_1 = require("@shahadul-17/utilities");
const parent_process_1 = require("./parent-process");
const child_process_1 = require("./child-process");
class Process {
constructor(options) {
const isChildProcess = utilities_1.ArgumentsParser.getArgument("isChildProcess") === "true";
options = utilities_1.ObjectUtilities.isObject(options)
? options
: utilities_1.ObjectUtilities.getEmptyObject(true);
this.process = isChildProcess
? new parent_process_1.ParentProcess(options)
: new child_process_1.ChildProcess(options);
// binding methods...
this.incrementTaskCount = this.incrementTaskCount.bind(this);
this.decrementTaskCount = this.decrementTaskCount.bind(this);
this.spawnAsync = this.spawnAsync.bind(this);
this.sendAsync = this.sendAsync.bind(this);
this.addEventListener = this.addEventListener.bind(this);
this.removeEventListener = this.removeEventListener.bind(this);
this.removeEventListeners = this.removeEventListeners.bind(this);
this.copyEventListeners = this.copyEventListeners.bind(this);
}
get isChildProcess() {
return this.process.isChildProcess;
}
get taskCount() {
return this.process.taskCount;
}
get processId() {
return this.process.processId;
}
get options() {
return this.process.options;
}
incrementTaskCount(step) {
return this.process.incrementTaskCount(step);
}
decrementTaskCount(step) {
return this.process.decrementTaskCount(step);
}
spawnAsync() {
return this.process.spawnAsync();
}
sendAsync(data) {
return this.process.sendAsync(data);
}
addEventListener(type, listener) {
return this.process.addEventListener(type, listener);
}
removeEventListener(listener, type, removeAll) {
return this.process.removeEventListener(listener, type, removeAll);
}
removeEventListeners(type) {
return this.process.removeEventListeners(type);
}
copyEventListeners(eventManager, type) {
return this.process.copyEventListeners(eventManager, type);
}
}
exports.Process = Process;
//# sourceMappingURL=process.js.map