2017-03-04 10:40:32 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const plugins = require("./smartipc.plugins");
|
2017-03-04 10:59:56 +00:00
|
|
|
const smartq = require("smartq");
|
2017-03-04 10:40:32 +00:00
|
|
|
const childProcess = require("child_process");
|
|
|
|
const smartipc_classes_thread_1 = require("./smartipc.classes.thread");
|
|
|
|
class ThreadSimple {
|
2017-03-04 11:24:32 +00:00
|
|
|
constructor(filePathArg, forkOptionsArg = {}) {
|
2017-03-04 10:40:32 +00:00
|
|
|
this.workerPath = filePathArg;
|
2017-03-04 11:24:32 +00:00
|
|
|
this.forkOptions = forkOptionsArg;
|
2017-03-04 10:40:32 +00:00
|
|
|
}
|
|
|
|
run() {
|
2017-03-04 10:59:56 +00:00
|
|
|
let done = smartq.defer();
|
2017-03-04 10:40:32 +00:00
|
|
|
let forkPath = (() => {
|
|
|
|
if (smartipc_classes_thread_1.workerBasePath) {
|
|
|
|
return plugins.path.join(smartipc_classes_thread_1.workerBasePath, this.workerPath);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.workerPath;
|
|
|
|
}
|
|
|
|
})();
|
2017-03-04 11:24:32 +00:00
|
|
|
this.threadChildProcess = childProcess.fork(forkPath, [], this.forkOptions);
|
2017-03-04 10:59:56 +00:00
|
|
|
done.resolve(this.threadChildProcess);
|
|
|
|
return done.promise;
|
2017-03-04 10:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.ThreadSimple = ThreadSimple;
|
2017-03-04 11:24:32 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWRzaW1wbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGlwYy5jbGFzc2VzLnRocmVhZHNpbXBsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQU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