add threadsimple for simple forking
This commit is contained in:
parent
661e782367
commit
347036cf4e
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
export * from './smartipc.classes.thread';
|
||||
export * from './smartipc.classes.threadfunction';
|
||||
export * from './smartipc.classes.threadsimple';
|
||||
export * from './smartipc.classes.pool';
|
||||
export * from './smartipc.wrap';
|
||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -5,6 +5,7 @@ function __export(m) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./smartipc.classes.thread"));
|
||||
__export(require("./smartipc.classes.threadfunction"));
|
||||
__export(require("./smartipc.classes.threadsimple"));
|
||||
__export(require("./smartipc.classes.pool"));
|
||||
__export(require("./smartipc.wrap"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLCtDQUF5QztBQUN6Qyx1REFBaUQ7QUFDakQsNkNBQXVDO0FBQ3ZDLHFDQUErQiJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLCtDQUF5QztBQUN6Qyx1REFBaUQ7QUFDakQscURBQStDO0FBQy9DLDZDQUF1QztBQUN2QyxxQ0FBK0IifQ==
|
2
dist/smartipc.classes.pool.js
vendored
2
dist/smartipc.classes.pool.js
vendored
@ -10,4 +10,4 @@ class Pool {
|
||||
}
|
||||
}
|
||||
exports.Pool = Pool;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy5wb29sLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRpcGMuY2xhc3Nlcy5wb29sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsOENBQTZDO0FBRTdDO0lBRUk7UUFDSSxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUMxQyxDQUFDO0lBQ0QsR0FBRyxDQUFDLGFBQXFCO1FBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUN2QyxDQUFDO0NBQ0o7QUFSRCxvQkFRQyJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy5wb29sLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRpcGMuY2xhc3Nlcy5wb29sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsOENBQTZDO0FBRTdDO0lBRUU7UUFDRSxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUN4QyxDQUFDO0lBQ0QsR0FBRyxDQUFDLGFBQXFCO1FBQ3ZCLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQTtJQUNyQyxDQUFDO0NBQ0Y7QUFSRCxvQkFRQyJ9
|
1
dist/smartipc.classes.thread.d.ts
vendored
1
dist/smartipc.classes.thread.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Pool } from './smartipc.classes.pool';
|
||||
export declare let workerBasePath: string;
|
||||
export declare let setWorkerBasePath: (basePathArg: string) => void;
|
||||
export declare class Thread {
|
||||
thread: any;
|
||||
|
6
dist/smartipc.classes.thread.js
vendored
6
dist/smartipc.classes.thread.js
vendored
@ -2,10 +2,12 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./smartipc.plugins");
|
||||
const q = require("smartq");
|
||||
exports.workerBasePath = null;
|
||||
exports.setWorkerBasePath = (basePathArg) => {
|
||||
exports.workerBasePath = basePathArg;
|
||||
plugins.threads.config.set({
|
||||
basepath: {
|
||||
node: basePathArg
|
||||
node: exports.workerBasePath
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -67,4 +69,4 @@ class Thread {
|
||||
}
|
||||
}
|
||||
exports.Thread = Thread;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGlwYy5jbGFzc2VzLnRocmVhZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDhDQUE2QztBQUM3Qyw0QkFBMkI7QUFJaEIsUUFBQSxpQkFBaUIsR0FBRyxDQUFDLFdBQW1CO0lBQ2pELE9BQU8sQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQztRQUN6QixRQUFRLEVBQUU7WUFDUixJQUFJLEVBQUUsV0FBVztTQUNsQjtLQUNGLENBQUMsQ0FBQTtBQUNKLENBQUMsQ0FBQTtBQUVEO0lBS0UsWUFBWSxXQUFtQjtRQUYvQixZQUFPLEdBQVksS0FBSyxDQUFBO1FBQ3hCLGlCQUFZLEdBQVMsSUFBSSxDQUFBO1FBRXZCLElBQUksQ0FBQyxVQUFVLEdBQUcsV0FBVyxDQUFBO0lBQy9CLENBQUM7SUFFRDs7O09BR0c7SUFDSCxJQUFJLENBQUksT0FBWTtRQUNsQixJQUFJLElBQUksR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FBQyxDQUFBO1FBQ3RELENBQUM7UUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTyxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDO1lBQzlDLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFBO1lBQ25CLElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ3RELENBQUM7SUFDSCxDQUFDO0NBQ0Y7QUE5REQsd0JBOERDIn0=
|
7
dist/smartipc.classes.threadsimple.d.ts
vendored
Normal file
7
dist/smartipc.classes.threadsimple.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import * as childProcess from 'child_process';
|
||||
export declare class ThreadSimple {
|
||||
workerPath: string;
|
||||
threadChildProcess: childProcess.ChildProcess;
|
||||
constructor(filePathArg: string);
|
||||
run(): childProcess.ChildProcess;
|
||||
}
|
24
dist/smartipc.classes.threadsimple.js
vendored
Normal file
24
dist/smartipc.classes.threadsimple.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./smartipc.plugins");
|
||||
const childProcess = require("child_process");
|
||||
const smartipc_classes_thread_1 = require("./smartipc.classes.thread");
|
||||
class ThreadSimple {
|
||||
constructor(filePathArg) {
|
||||
this.workerPath = filePathArg;
|
||||
}
|
||||
run() {
|
||||
let forkPath = (() => {
|
||||
if (smartipc_classes_thread_1.workerBasePath) {
|
||||
return plugins.path.join(smartipc_classes_thread_1.workerBasePath, this.workerPath);
|
||||
}
|
||||
else {
|
||||
return this.workerPath;
|
||||
}
|
||||
})();
|
||||
this.threadChildProcess = childProcess.fork(forkPath);
|
||||
return this.threadChildProcess;
|
||||
}
|
||||
}
|
||||
exports.ThreadSimple = ThreadSimple;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMuY2xhc3Nlcy50aHJlYWRzaW1wbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGlwYy5jbGFzc2VzLnRocmVhZHNpbXBsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDhDQUE2QztBQUU3Qyw4Q0FBNkM7QUFFN0MsdUVBQTBEO0FBRTFEO0lBR0UsWUFBYSxXQUFtQjtRQUM5QixJQUFJLENBQUMsVUFBVSxHQUFHLFdBQVcsQ0FBQTtJQUMvQixDQUFDO0lBRUQsR0FBRztRQUNELElBQUksUUFBUSxHQUFHLENBQUM7WUFDZCxFQUFFLENBQUMsQ0FBQyx3Q0FBYyxDQUFDLENBQUMsQ0FBQztnQkFDbkIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHdDQUFjLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1lBQzNELENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDTixNQUFNLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQTtZQUN4QixDQUFDO1FBQ0gsQ0FBQyxDQUFDLEVBQUUsQ0FBQTtRQUNKLElBQUksQ0FBQyxrQkFBa0IsR0FBRyxZQUFZLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFBO1FBQ3JELE1BQU0sQ0FBQyxJQUFJLENBQUMsa0JBQWtCLENBQUE7SUFDaEMsQ0FBQztDQUNGO0FBbEJELG9DQWtCQyJ9
|
3
dist/smartipc.plugins.d.ts
vendored
3
dist/smartipc.plugins.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import 'typings-global';
|
||||
import * as path from 'path';
|
||||
declare let threads: any;
|
||||
import * as smartq from 'smartq';
|
||||
export { smartq, threads };
|
||||
export { path, smartq, threads };
|
||||
|
4
dist/smartipc.plugins.js
vendored
4
dist/smartipc.plugins.js
vendored
@ -1,8 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const path = require("path");
|
||||
exports.path = path;
|
||||
let threads = require('threads');
|
||||
exports.threads = threads;
|
||||
const smartq = require("smartq");
|
||||
exports.smartq = smartq;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBSzVCLDBCQUFPO0FBSlgsaUNBQWdDO0FBRzVCLHdCQUFNIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsNkJBQTRCO0FBS3hCLG9CQUFJO0FBSlIsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBTTVCLDBCQUFPO0FBTFgsaUNBQWdDO0FBSTVCLHdCQUFNIn0=
|
2
dist/smartipc.wrap.d.ts
vendored
2
dist/smartipc.wrap.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
export declare let startSpawnWrap: (filePath: string, cliArgs: string[], envArgs: any) => void;
|
||||
export declare let startSpawnWrap: (filePath: string, cliArgs?: string[], envArgs?: any) => void;
|
||||
export declare let endSpawnWrap: () => void;
|
||||
|
4
dist/smartipc.wrap.js
vendored
4
dist/smartipc.wrap.js
vendored
@ -2,7 +2,7 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const spawnWrap = require("spawn-wrap");
|
||||
let unwrap = null;
|
||||
exports.startSpawnWrap = (filePath, cliArgs, envArgs) => {
|
||||
exports.startSpawnWrap = (filePath, cliArgs = [], envArgs = {}) => {
|
||||
let spawnArray = [filePath];
|
||||
for (let cliArg of cliArgs) {
|
||||
spawnArray.push(cliArg);
|
||||
@ -15,4 +15,4 @@ exports.endSpawnWrap = () => {
|
||||
unwrap = null;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMud3JhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLndyYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3Q0FBdUM7QUFFdkMsSUFBSSxNQUFNLEdBQVEsSUFBSSxDQUFBO0FBRVgsUUFBQSxjQUFjLEdBQUcsQ0FBQyxRQUFnQixFQUFFLE9BQWlCLEVBQUUsT0FBWTtJQUM1RSxJQUFJLFVBQVUsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0lBQzNCLEdBQUcsQ0FBQyxDQUFDLElBQUksTUFBTSxJQUFJLE9BQU8sQ0FBQyxDQUFDLENBQUM7UUFDM0IsVUFBVSxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUN6QixDQUFDO0lBQ0QsTUFBTSxHQUFHLFNBQVMsQ0FBQyxVQUFVLEVBQUUsT0FBTyxDQUFDLENBQUE7QUFDekMsQ0FBQyxDQUFBO0FBRVUsUUFBQSxZQUFZLEdBQUc7SUFDeEIsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUNYLE1BQU0sRUFBRSxDQUFBO1FBQ1IsTUFBTSxHQUFHLElBQUksQ0FBQTtJQUNmLENBQUM7QUFDSCxDQUFDLENBQUEifQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpcGMud3JhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aXBjLndyYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3Q0FBdUM7QUFFdkMsSUFBSSxNQUFNLEdBQVEsSUFBSSxDQUFBO0FBRVgsUUFBQSxjQUFjLEdBQUcsQ0FBQyxRQUFnQixFQUFFLFVBQW9CLEVBQUUsRUFBRSxVQUFlLEVBQUU7SUFDdEYsSUFBSSxVQUFVLEdBQUcsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUMzQixHQUFHLENBQUMsQ0FBQyxJQUFJLE1BQU0sSUFBSSxPQUFPLENBQUMsQ0FBQyxDQUFDO1FBQzNCLFVBQVUsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUE7SUFDekIsQ0FBQztJQUNELE1BQU0sR0FBRyxTQUFTLENBQUMsVUFBVSxFQUFFLE9BQU8sQ0FBQyxDQUFBO0FBQ3pDLENBQUMsQ0FBQTtBQUVVLFFBQUEsWUFBWSxHQUFHO0lBQ3hCLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDWCxNQUFNLEVBQUUsQ0FBQTtRQUNSLE1BQU0sR0FBRyxJQUFJLENBQUE7SUFDZixDQUFDO0FBQ0gsQ0FBQyxDQUFBIn0=
|
@ -1,4 +1,6 @@
|
||||
export * from './smartipc.classes.thread'
|
||||
export * from './smartipc.classes.threadfunction'
|
||||
export * from './smartipc.classes.threadsimple'
|
||||
export * from './smartipc.classes.pool'
|
||||
export * from './smartipc.wrap'
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as plugins from './smartipc.plugins'
|
||||
|
||||
export class Pool {
|
||||
pool
|
||||
constructor() {
|
||||
this.pool = new plugins.threads.Pool()
|
||||
}
|
||||
run(workerPathArg: string) {
|
||||
return this.pool.run(workerPathArg)
|
||||
}
|
||||
pool
|
||||
constructor() {
|
||||
this.pool = new plugins.threads.Pool()
|
||||
}
|
||||
run(workerPathArg: string) {
|
||||
return this.pool.run(workerPathArg)
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ import * as q from 'smartq'
|
||||
|
||||
import { Pool } from './smartipc.classes.pool'
|
||||
|
||||
export let workerBasePath: string = null
|
||||
|
||||
export let setWorkerBasePath = (basePathArg: string) => {
|
||||
workerBasePath = basePathArg
|
||||
plugins.threads.config.set({
|
||||
basepath: {
|
||||
node: basePathArg
|
||||
node: workerBasePath
|
||||
}
|
||||
})
|
||||
}
|
||||
|
25
ts/smartipc.classes.threadsimple.ts
Normal file
25
ts/smartipc.classes.threadsimple.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as plugins from './smartipc.plugins'
|
||||
import * as q from 'smartq'
|
||||
import * as childProcess from 'child_process'
|
||||
|
||||
import { workerBasePath } from './smartipc.classes.thread'
|
||||
|
||||
export class ThreadSimple {
|
||||
workerPath: string
|
||||
threadChildProcess: childProcess.ChildProcess
|
||||
constructor (filePathArg: string) {
|
||||
this.workerPath = filePathArg
|
||||
}
|
||||
|
||||
run () {
|
||||
let forkPath = (() => {
|
||||
if (workerBasePath) {
|
||||
return plugins.path.join(workerBasePath, this.workerPath)
|
||||
} else {
|
||||
return this.workerPath
|
||||
}
|
||||
})()
|
||||
this.threadChildProcess = childProcess.fork(forkPath)
|
||||
return this.threadChildProcess
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import 'typings-global'
|
||||
import * as path from 'path'
|
||||
let threads = require('threads')
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
export {
|
||||
path,
|
||||
smartq,
|
||||
threads
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user