4 Commits

Author SHA1 Message Date
9d33a5df53 1.0.7 2017-03-04 12:05:57 +01:00
57ddf4c45d improve typings 2017-03-04 12:05:53 +01:00
1329513543 1.0.6 2017-03-04 11:59:58 +01:00
e1acfd03e6 ThreadSimple is now returning a Promise 2017-03-04 11:59:56 +01:00
4 changed files with 11 additions and 6 deletions

View File

@ -3,5 +3,5 @@ export declare class ThreadSimple {
workerPath: string; workerPath: string;
threadChildProcess: childProcess.ChildProcess; threadChildProcess: childProcess.ChildProcess;
constructor(filePathArg: string); constructor(filePathArg: string);
run(): childProcess.ChildProcess; run(): Promise<childProcess.ChildProcess>;
} }

View File

@ -1,6 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartipc.plugins"); const plugins = require("./smartipc.plugins");
const smartq = require("smartq");
const childProcess = require("child_process"); const childProcess = require("child_process");
const smartipc_classes_thread_1 = require("./smartipc.classes.thread"); const smartipc_classes_thread_1 = require("./smartipc.classes.thread");
class ThreadSimple { class ThreadSimple {
@ -8,6 +9,7 @@ class ThreadSimple {
this.workerPath = filePathArg; this.workerPath = filePathArg;
} }
run() { run() {
let done = smartq.defer();
let forkPath = (() => { let forkPath = (() => {
if (smartipc_classes_thread_1.workerBasePath) { if (smartipc_classes_thread_1.workerBasePath) {
return plugins.path.join(smartipc_classes_thread_1.workerBasePath, this.workerPath); return plugins.path.join(smartipc_classes_thread_1.workerBasePath, this.workerPath);
@ -17,8 +19,9 @@ class ThreadSimple {
} }
})(); })();
this.threadChildProcess = childProcess.fork(forkPath); this.threadChildProcess = childProcess.fork(forkPath);
return this.threadChildProcess; done.resolve(this.threadChildProcess);
return done.promise;
} }
} }
exports.ThreadSimple = ThreadSimple; exports.ThreadSimple = ThreadSimple;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWRzaW1wbGUuanMiLCJzb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0FBRTdDLHVFQUEwRDtBQUUxRDtJQUdFLFlBQWEsV0FBbUI7UUFDOUIsSUFBSSxDQUFDLFVBQVUsR0FBRyxXQUFXLENBQUE7SUFDL0IsQ0FBQztJQUVELEdBQUc7UUFDRCxJQUFJLElBQUksR0FBRyxNQUFNLENBQUMsS0FBSyxFQUE2QixDQUFBO1FBQ3BELElBQUksUUFBUSxHQUFHLENBQUM7WUFDZCxFQUFFLENBQUMsQ0FBQyx3Q0FBYyxDQUFDLENBQUMsQ0FBQztnQkFDbkIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHdDQUFjLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1lBQzNELENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDTixNQUFNLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQTtZQUN4QixDQUFDO1FBQ0gsQ0FBQyxDQUFDLEVBQUUsQ0FBQTtRQUNKLElBQUksQ0FBQyxrQkFBa0IsR0FBRyxZQUFZLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFBO1FBQ3JELElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLGtCQUFrQixDQUFDLENBQUE7UUFDckMsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDckIsQ0FBQztDQUNGO0FBcEJELG9DQW9CQyJ9

View File

@ -1,6 +1,6 @@
{ {
"name": "smartipc", "name": "smartipc",
"version": "1.0.5", "version": "1.0.7",
"description": "smart subprocess handling", "description": "smart subprocess handling",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@ -1,5 +1,5 @@
import * as plugins from './smartipc.plugins' import * as plugins from './smartipc.plugins'
import * as q from 'smartq' import * as smartq from 'smartq'
import * as childProcess from 'child_process' import * as childProcess from 'child_process'
import { workerBasePath } from './smartipc.classes.thread' import { workerBasePath } from './smartipc.classes.thread'
@ -12,6 +12,7 @@ export class ThreadSimple {
} }
run () { run () {
let done = smartq.defer<childProcess.ChildProcess>()
let forkPath = (() => { let forkPath = (() => {
if (workerBasePath) { if (workerBasePath) {
return plugins.path.join(workerBasePath, this.workerPath) return plugins.path.join(workerBasePath, this.workerPath)
@ -20,6 +21,7 @@ export class ThreadSimple {
} }
})() })()
this.threadChildProcess = childProcess.fork(forkPath) this.threadChildProcess = childProcess.fork(forkPath)
return this.threadChildProcess done.resolve(this.threadChildProcess)
return done.promise
} }
} }