Comparing version 0.0.59 to 0.0.60
@@ -19,9 +19,9 @@ /** | ||
}; | ||
register(name: N, process: Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void; | ||
register(name: N, process: Supervisor.Process<P, R, S>, state: S): (reason?: any) => void; | ||
register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void; | ||
register(name: N, process: Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => boolean; | ||
register(name: N, process: Supervisor.Process<P, R, S>, state: S): (reason?: any) => boolean; | ||
register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => boolean; | ||
call(name: N, param: P, callback: Supervisor.Callback<R>, timeout?: number): void; | ||
cast(name: N, param: P, timeout?: number): boolean; | ||
refs(name?: N): [N, Supervisor.Process<P, R, S>, S, (reason: any) => void][]; | ||
terminate(name?: N, reason?: any): void; | ||
refs(name?: N): [N, Supervisor.Process<P, R, S>, S, (reason: any) => boolean][]; | ||
terminate(name?: N, reason?: any): boolean; | ||
} | ||
@@ -471,15 +471,15 @@ export namespace Supervisor { | ||
export function assign<T extends U, U extends object>(target: T, ...sources: Partial<U>[]): T; | ||
export function assign<T extends U, U extends object>(target: {}, source: T, ...sources: Partial<U>[]): T; | ||
export function assign<T extends U, U extends object>(target: object, source: T, ...sources: Partial<U>[]): T; | ||
export function assign<T extends object>(target: T, ...sources: Partial<T>[]): T; | ||
export function assign<T extends object>(target: {}, source: T, ...sources: Partial<T>[]): T; | ||
export function assign<T extends object>(target: object, source: T, ...sources: Partial<T>[]): T; | ||
export function clone<T extends U, U extends object>(target: T, ...sources: Partial<U>[]): T; | ||
export function clone<T extends U, U extends object>(target: {}, source: T, ...sources: Partial<U>[]): T; | ||
export function clone<T extends U, U extends object>(target: object, source: T, ...sources: Partial<U>[]): T; | ||
export function clone<T extends object>(target: T, ...sources: Partial<T>[]): T; | ||
export function clone<T extends object>(target: {}, source: T, ...sources: Partial<T>[]): T; | ||
export function clone<T extends object>(target: object, source: T, ...sources: Partial<T>[]): T; | ||
export function extend<T extends U, U extends object>(target: T, ...sources: Partial<U>[]): T; | ||
export function extend<T extends U, U extends object>(target: {}, source: T, ...sources: Partial<U>[]): T; | ||
export function extend<T extends U, U extends object>(target: object, source: T, ...sources: Partial<U>[]): T; | ||
export function extend<T extends object>(target: T, ...sources: Partial<T>[]): T; | ||
export function extend<T extends object>(target: {}, source: T, ...sources: Partial<T>[]): T; | ||
export function extend<T extends object>(target: object, source: T, ...sources: Partial<T>[]): T; | ||
export function concat<T>(target: T[], source: T[]): T[]; | ||
export function concat<T>(target: T[], source: { [index: number]: T; length: number; }): T[]; | ||
export function sort<T>(as: T[], cmp: (a: T, b: T) => number, times: number): T[]; |
{ | ||
"name": "spica", | ||
"version": "0.0.59", | ||
"version": "0.0.60", | ||
"description": "Supervisor/Actor, Observable, Sequence, Maybe, Either and some utils.", | ||
@@ -44,3 +44,3 @@ "private": false, | ||
"benchmark": "^2.1.4", | ||
"browserify": "^14.1.0", | ||
"browserify": "^14.3.0", | ||
"del": "^2.2.2", | ||
@@ -55,3 +55,3 @@ "extend": "^3.0.0", | ||
"gulp-unassert": "^1.0.1", | ||
"karma": "^1.5.0", | ||
"karma": "^1.6.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
@@ -66,7 +66,7 @@ "karma-coverage": "^1.1.1", | ||
"mocha": "^3.2.0", | ||
"npm-check-updates": "^2.10.4", | ||
"npm-check-updates": "^2.10.5", | ||
"power-assert": "^1.4.2", | ||
"run-sequence": "^1.2.2", | ||
"tsify": "^3.0.1", | ||
"typescript": "2.3.0-dev.20170403", | ||
"typescript": "2.3.0-dev.20170413", | ||
"vinyl-buffer": "^1.0.0", | ||
@@ -73,0 +73,0 @@ "vinyl-source-stream": "^1.1.0" |
@@ -41,5 +41,5 @@ import { type } from './type'; | ||
function walk<T extends U, U extends object>(target: T, ...sources: Partial<U>[]): T; | ||
function walk<T extends U, U extends object>(target: {}, source: T, ...sources: Partial<U>[]): T; | ||
function walk<T extends U, U extends object>(target: object, source: T, ...sources: Partial<U>[]): T; | ||
function walk<T extends object>(target: T, ...sources: Partial<T>[]): T; | ||
function walk<T extends object>(target: {}, source: T, ...sources: Partial<T>[]): T; | ||
function walk<T extends object>(target: object, source: T, ...sources: Partial<T>[]): T; | ||
function walk<T extends U, U extends object>(target: T, ...sources: Partial<U>[]): T { | ||
@@ -46,0 +46,0 @@ if (target === undefined || target === null) { |
@@ -251,2 +251,25 @@ import { Supervisor } from './supervisor'; | ||
it('terminate process', function (done) { | ||
class TestSupervisor extends Supervisor<string, number, number, number> { | ||
} | ||
assert(TestSupervisor.count === 0); | ||
assert(TestSupervisor.procs === 0); | ||
const sv = new TestSupervisor({}); | ||
assert(TestSupervisor.count === 1); | ||
assert(TestSupervisor.procs === 0); | ||
void sv.register(' ', _ => [0, 0], 0); | ||
assert(TestSupervisor.count === 1); | ||
assert(TestSupervisor.procs === 1); | ||
assert(sv.terminate('') === false); | ||
assert(TestSupervisor.count === 1); | ||
assert(TestSupervisor.procs === 1); | ||
assert(sv.terminate(' ') === true); | ||
assert(TestSupervisor.count === 1); | ||
assert(TestSupervisor.procs === 0); | ||
assert(sv.terminate() === true); | ||
assert(TestSupervisor.count === 0); | ||
assert(TestSupervisor.procs === 0); | ||
done(); | ||
}); | ||
it('terminate', function (done) { | ||
@@ -268,5 +291,5 @@ let cnt = 0; | ||
const terminate = sv.register('', _ => [0, 0], 0); | ||
sv.terminate(); | ||
terminate(); | ||
sv.terminate(); | ||
assert(sv.terminate() === true); | ||
assert(terminate() === false); | ||
assert(sv.terminate() === false); | ||
assert(cnt === 1); | ||
@@ -273,0 +296,0 @@ try { |
@@ -27,3 +27,7 @@ import { Supervisor as ISupervisor } from '../../index.d'; | ||
assert(this.alive === true); | ||
assert(this.available === false); | ||
assert(this.available === true); | ||
this.available = false; | ||
void Array.from(this.workers.values()) | ||
.forEach(worker => | ||
void worker.terminate(reason)); | ||
assert(this.workers.size === 0); | ||
@@ -42,2 +46,4 @@ void this.deliver(); | ||
void Object.freeze(this); | ||
assert(this.alive === false); | ||
assert(this.available === false); | ||
} | ||
@@ -60,6 +66,6 @@ public readonly id: string = sqid(); | ||
} | ||
public register(name: N, process: Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void; | ||
public register(name: N, process: Supervisor.Process<P, R, S>, state: S): (reason?: any) => void; | ||
public register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void; | ||
public register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void { | ||
public register(name: N, process: Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => boolean; | ||
public register(name: N, process: Supervisor.Process<P, R, S>, state: S): (reason?: any) => boolean; | ||
public register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => boolean; | ||
public register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => boolean { | ||
void this.validate(); | ||
@@ -118,3 +124,3 @@ if (this.workers.has(name)) throw new Error(`Spica: Supervisor: <${this.id}/${this.name}/${name}>: Cannot register a process multiply with the same name.`); | ||
} | ||
public refs(name?: N): [N, Supervisor.Process<P, R, S>, S, (reason: any) => void][] { | ||
public refs(name?: N): [N, Supervisor.Process<P, R, S>, S, (reason: any) => boolean][] { | ||
void this.validate(); | ||
@@ -127,3 +133,3 @@ return name === void 0 | ||
function convert(worker: Worker<N, P, R, S>): [N, Supervisor.Process<P, R, S>, S, (reason: any) => void] { | ||
function convert(worker: Worker<N, P, R, S>): [N, Supervisor.Process<P, R, S>, S, (reason: any) => boolean] { | ||
assert(worker instanceof Worker); | ||
@@ -138,15 +144,11 @@ return [ | ||
} | ||
public terminate(name?: N, reason?: any): void { | ||
if (!this.available) return; | ||
public terminate(name?: N, reason?: any): boolean { | ||
if (!this.available) return false; | ||
assert(this.alive === true); | ||
if (name === void 0) { | ||
this.available = false; | ||
} | ||
void Array.from(this.workers.values()) | ||
.forEach(worker => | ||
void worker.terminate(reason)); | ||
assert(this.workers.size === 0); | ||
if (name === void 0) { | ||
void this.destructor(reason); | ||
} | ||
return name === void 0 | ||
? void this.destructor(reason) === void 0 | ||
: Array.from(this.workers.values()) | ||
.filter(worker => worker.name === name) | ||
.filter(worker => worker.terminate(reason)) | ||
.length > 0; | ||
} | ||
@@ -250,2 +252,4 @@ public schedule(): void { | ||
void Object.freeze(this); | ||
assert(this.alive === false); | ||
assert(this.available === false); | ||
try { | ||
@@ -310,5 +314,6 @@ void this.process.exit(reason, this.state); | ||
} | ||
public readonly terminate = (reason: any): void => { | ||
if (!this.alive) return; | ||
public readonly terminate = (reason: any): boolean => { | ||
if (!this.alive) return false; | ||
void this.destructor(reason); | ||
return true; | ||
} | ||
@@ -315,0 +320,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
497878
11372