@quenk/potoo 4.1.15 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actor/api.d.ts +7 -1
- package/lib/actor/framework/process.d.ts +1 -31
- package/lib/actor/framework/process.js +15 -65
- package/lib/actor/framework/process.js.map +1 -1
- package/lib/actor/framework/resident.d.ts +1 -54
- package/lib/actor/framework/resident.js +4 -71
- package/lib/actor/framework/resident.js.map +1 -1
- package/lib/actor/index.d.ts +9 -0
- package/lib/actor/local/index.d.ts +84 -0
- package/lib/actor/local/index.js +114 -0
- package/lib/actor/local/index.js.map +1 -0
- package/lib/actor/process.d.ts +31 -0
- package/lib/actor/process.js +68 -0
- package/lib/actor/process.js.map +1 -0
- package/lib/actor/system/vm/event/dispatcher.js +3 -1
- package/lib/actor/system/vm/event/dispatcher.js.map +1 -1
- package/lib/actor/system/vm/index.d.ts +1 -0
- package/lib/actor/system/vm/index.js +1 -0
- package/lib/actor/system/vm/index.js.map +1 -1
- package/lib/actor/system/vm/runtime.d.ts +32 -1
- package/lib/actor/system/vm/thread/collector.d.ts +2 -2
- package/lib/actor/system/vm/thread/collector.js +2 -2
- package/lib/actor/system/vm/thread/runner.js +6 -1
- package/lib/actor/system/vm/thread/runner.js.map +1 -1
- package/lib/actor/system/vm/thread/shared/js.d.ts +10 -2
- package/lib/actor/system/vm/thread/shared/js.js +28 -1
- package/lib/actor/system/vm/thread/shared/js.js.map +1 -1
- package/lib/actor/template.d.ts +13 -1
- package/lib/actor/template.js.map +1 -1
- package/package.json +1 -1
package/lib/actor/api.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Err } from '@quenk/noni/lib/control/error';
|
|
2
|
+
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
2
3
|
import { Address } from './address';
|
|
3
4
|
import { Spawnable } from './template';
|
|
4
5
|
import { Message } from '.';
|
|
5
|
-
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
6
6
|
/**
|
|
7
7
|
* Parent is any object capable of spawning a child actor.
|
|
8
8
|
*/
|
|
@@ -33,6 +33,12 @@ export interface Api extends Parent {
|
|
|
33
33
|
* An actor can only specify itself or a child as the target.
|
|
34
34
|
*/
|
|
35
35
|
kill(target: Address): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* exit kills the actor.
|
|
38
|
+
*
|
|
39
|
+
* A value can be optionally provided to return to the parent.
|
|
40
|
+
*/
|
|
41
|
+
exit<T>(value?: T): Promise<void>;
|
|
36
42
|
/**
|
|
37
43
|
* tell a message to an actor address.
|
|
38
44
|
*/
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Address } from '../address';
|
|
3
|
-
/**
|
|
4
|
-
* init should be called as early as possible in the child process if using the
|
|
5
|
-
* direct API (Process).
|
|
6
|
-
*
|
|
7
|
-
* It sets up a listener for incoming messages to the child_process that can
|
|
8
|
-
* be read later via receive() or select().
|
|
9
|
-
*/
|
|
10
|
-
export declare const init: () => void;
|
|
11
|
-
/**
|
|
12
|
-
* self provides the address for this child actor.
|
|
13
|
-
*/
|
|
14
|
-
export declare const self: string;
|
|
15
|
-
/**
|
|
16
|
-
* tell sends a message to another actor in the system using the VM in the
|
|
17
|
-
* parent process.
|
|
18
|
-
*/
|
|
19
|
-
export declare const tell: <M>(to: Address, message: M) => any;
|
|
20
|
-
/**
|
|
21
|
-
* receive the next message in the message queue.
|
|
22
|
-
*
|
|
23
|
-
* TODO: drop messages that do not match any cases.
|
|
24
|
-
*/
|
|
25
|
-
export declare const receive: <T>(cases?: Case<T>[]) => Promise<T>;
|
|
26
|
-
/**
|
|
27
|
-
* exit the actor, ending the process as a result.
|
|
28
|
-
*
|
|
29
|
-
* This is simply a wrapper around process.exit();
|
|
30
|
-
*/
|
|
31
|
-
export declare const exit: () => never;
|
|
1
|
+
export * from '../process';
|
|
@@ -1,68 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
const init = () => {
|
|
17
|
-
if (!process.send)
|
|
18
|
-
throw new Error('process: direct API is meant to ' + 'be used in a child process!');
|
|
19
|
-
process.on('message', (m) => {
|
|
20
|
-
messages.unshift(m);
|
|
21
|
-
drain();
|
|
22
|
-
});
|
|
23
|
-
process.on('uncaughtExceptionMonitor', err => process.send(err));
|
|
24
|
-
};
|
|
25
|
-
exports.init = init;
|
|
26
|
-
/**
|
|
27
|
-
* self provides the address for this child actor.
|
|
28
|
-
*/
|
|
29
|
-
exports.self = process.env.POTOO_ACTOR_ADDRESS || address_1.ADDRESS_DISCARD;
|
|
30
|
-
/**
|
|
31
|
-
* tell sends a message to another actor in the system using the VM in the
|
|
32
|
-
* parent process.
|
|
33
|
-
*/
|
|
34
|
-
const tell = (to, message) => process.send({ from: exports.self, to, message });
|
|
35
|
-
exports.tell = tell;
|
|
36
|
-
const receivers = [];
|
|
37
|
-
const defaultCases = [new case_1.Default(function_1.identity)];
|
|
38
|
-
/**
|
|
39
|
-
* receive the next message in the message queue.
|
|
40
|
-
*
|
|
41
|
-
* TODO: drop messages that do not match any cases.
|
|
42
|
-
*/
|
|
43
|
-
const receive = async (cases = defaultCases) => new Promise(resolve => {
|
|
44
|
-
let matcher = new case_1.CaseFunction(cases || defaultCases);
|
|
45
|
-
let receiver = async (msg) => {
|
|
46
|
-
if (matcher.test(msg)) {
|
|
47
|
-
resolve(await matcher.apply(msg));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
receivers.push(receiver);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
receivers.push(receiver);
|
|
54
|
-
drain();
|
|
55
|
-
});
|
|
56
|
-
exports.receive = receive;
|
|
57
|
-
const drain = () => {
|
|
58
|
-
if (!(0, array_1.empty)(messages) && !(0, array_1.empty)(receivers))
|
|
59
|
-
receivers.pop()(messages.shift());
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
60
15
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
* This is simply a wrapper around process.exit();
|
|
65
|
-
*/
|
|
66
|
-
const exit = () => process.exit();
|
|
67
|
-
exports.exit = exit;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../process"), exports);
|
|
68
18
|
//# sourceMappingURL=process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../../src/actor/framework/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../../src/actor/framework/process.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Runtime } from '../system/vm/runtime';
|
|
3
|
-
import { Address } from '../address';
|
|
4
|
-
import { Spawnable } from '../template';
|
|
5
|
-
import { Api } from '../api';
|
|
6
|
-
import { Message, Actor } from '../';
|
|
7
|
-
import { Case } from '.';
|
|
8
|
-
/**
|
|
9
|
-
* Resident is an actor that exists in the current runtime.
|
|
10
|
-
*/
|
|
11
|
-
export interface Resident extends Api, Actor {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* AbstractResident is a base implementation of a Resident actor.
|
|
15
|
-
*/
|
|
16
|
-
export declare abstract class AbstractResident implements Resident {
|
|
17
|
-
runtime: Runtime;
|
|
18
|
-
constructor(runtime: Runtime);
|
|
19
|
-
self: string;
|
|
20
|
-
notify(msg: Message): Promise<void>;
|
|
21
|
-
spawn(target: Spawnable): Promise<string>;
|
|
22
|
-
tell<M>(addr: Address, msg: M): Promise<void>;
|
|
23
|
-
raise(err: Err): Promise<void>;
|
|
24
|
-
kill(addr: Address): Promise<void>;
|
|
25
|
-
exit(): Promise<void>;
|
|
26
|
-
start(): Promise<void>;
|
|
27
|
-
run(): Promise<void>;
|
|
28
|
-
stop(): Promise<void>;
|
|
29
|
-
receive<T>(cases?: Case<T>[]): Promise<T>;
|
|
30
|
-
watch<T>(task: () => Promise<T>): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Mutable actors can change their behaviour after message processing.
|
|
34
|
-
*/
|
|
35
|
-
export declare abstract class Mutable extends AbstractResident {
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Immutable is an actor whose behaviour does not change when a message is
|
|
39
|
-
* received.
|
|
40
|
-
*
|
|
41
|
-
* For each message received, the same set of TypeCase classes are applied.
|
|
42
|
-
* This class is useful for simple request/response style actors that do
|
|
43
|
-
* not require much complicated logic.
|
|
44
|
-
*
|
|
45
|
-
* @typeparam T - The type of messages the actor is interested in receiving.
|
|
46
|
-
*/
|
|
47
|
-
export declare abstract class Immutable extends AbstractResident {
|
|
48
|
-
/**
|
|
49
|
-
* selectors provides the list of TypeCase classes that will be applied to
|
|
50
|
-
* all incoming messages.
|
|
51
|
-
*/
|
|
52
|
-
selectors(): Case<Promise<void> | void>[];
|
|
53
|
-
start(): Promise<void>;
|
|
54
|
-
}
|
|
1
|
+
export { Immutable, Mutable } from '../local';
|
|
@@ -1,74 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class AbstractResident {
|
|
8
|
-
constructor(runtime) {
|
|
9
|
-
this.runtime = runtime;
|
|
10
|
-
this.self = this.runtime.self;
|
|
11
|
-
}
|
|
12
|
-
async notify(msg) {
|
|
13
|
-
await this.runtime.notify(msg);
|
|
14
|
-
}
|
|
15
|
-
spawn(target) {
|
|
16
|
-
return this.runtime.spawn(target);
|
|
17
|
-
}
|
|
18
|
-
async tell(addr, msg) {
|
|
19
|
-
await this.runtime.tell(addr, msg);
|
|
20
|
-
}
|
|
21
|
-
async raise(err) {
|
|
22
|
-
await this.runtime.raise(err);
|
|
23
|
-
}
|
|
24
|
-
async kill(addr) {
|
|
25
|
-
await this.runtime.kill(addr);
|
|
26
|
-
}
|
|
27
|
-
async exit() {
|
|
28
|
-
await this.runtime.kill(this.self);
|
|
29
|
-
}
|
|
30
|
-
async start() {
|
|
31
|
-
return this.run();
|
|
32
|
-
}
|
|
33
|
-
async run() { }
|
|
34
|
-
async stop() { }
|
|
35
|
-
async receive(cases = []) {
|
|
36
|
-
return this.runtime.receive(cases);
|
|
37
|
-
}
|
|
38
|
-
watch(task) {
|
|
39
|
-
return this.runtime.watch(task);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.AbstractResident = AbstractResident;
|
|
43
|
-
/**
|
|
44
|
-
* Mutable actors can change their behaviour after message processing.
|
|
45
|
-
*/
|
|
46
|
-
class Mutable extends AbstractResident {
|
|
47
|
-
}
|
|
48
|
-
exports.Mutable = Mutable;
|
|
49
|
-
/**
|
|
50
|
-
* Immutable is an actor whose behaviour does not change when a message is
|
|
51
|
-
* received.
|
|
52
|
-
*
|
|
53
|
-
* For each message received, the same set of TypeCase classes are applied.
|
|
54
|
-
* This class is useful for simple request/response style actors that do
|
|
55
|
-
* not require much complicated logic.
|
|
56
|
-
*
|
|
57
|
-
* @typeparam T - The type of messages the actor is interested in receiving.
|
|
58
|
-
*/
|
|
59
|
-
class Immutable extends AbstractResident {
|
|
60
|
-
/**
|
|
61
|
-
* selectors provides the list of TypeCase classes that will be applied to
|
|
62
|
-
* all incoming messages.
|
|
63
|
-
*/
|
|
64
|
-
selectors() {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
async start() {
|
|
68
|
-
await this.run();
|
|
69
|
-
while (this.runtime.isValid())
|
|
70
|
-
await this.receive(this.selectors());
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.Immutable = Immutable;
|
|
3
|
+
exports.Mutable = exports.Immutable = void 0;
|
|
4
|
+
var local_1 = require("../local");
|
|
5
|
+
Object.defineProperty(exports, "Immutable", { enumerable: true, get: function () { return local_1.Immutable; } });
|
|
6
|
+
Object.defineProperty(exports, "Mutable", { enumerable: true, get: function () { return local_1.Mutable; } });
|
|
74
7
|
//# sourceMappingURL=resident.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resident.js","sourceRoot":"","sources":["../../../src/actor/framework/resident.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"resident.js","sourceRoot":"","sources":["../../../src/actor/framework/resident.ts"],"names":[],"mappings":";;;AAAA,kCAA8C;AAArC,kGAAA,SAAS,OAAA;AAAE,gGAAA,OAAO,OAAA"}
|
package/lib/actor/index.d.ts
CHANGED
|
@@ -29,3 +29,12 @@ export interface Actor {
|
|
|
29
29
|
*/
|
|
30
30
|
stop(): Promise<void>;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Runnable is an extended actor interface used mainly by the fork machinery.
|
|
34
|
+
*/
|
|
35
|
+
export interface Runnable<T> extends Actor {
|
|
36
|
+
/**
|
|
37
|
+
* run is invoked by the Runnable's start() method.
|
|
38
|
+
*/
|
|
39
|
+
run(): Promise<T>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Err } from '@quenk/noni/lib/control/error';
|
|
2
|
+
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
3
|
+
import { MessagePredicate, Runtime } from '../system/vm/runtime';
|
|
4
|
+
import { Address } from '../address';
|
|
5
|
+
import { Forkable, Spawnable } from '../template';
|
|
6
|
+
import { Api } from '../api';
|
|
7
|
+
import { Message, Actor, Runnable } from '../';
|
|
8
|
+
export { TypeCase, Default } from '@quenk/noni/lib/control/match/case';
|
|
9
|
+
export { Case };
|
|
10
|
+
/**
|
|
11
|
+
* Local is an actor that exists in the current runtime.
|
|
12
|
+
*/
|
|
13
|
+
export interface Local extends Api, Actor {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* BaseLocal is a base implementation of a Local actor.
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class BaseLocal implements Local {
|
|
19
|
+
runtime: Runtime;
|
|
20
|
+
constructor(runtime: Runtime);
|
|
21
|
+
self: string;
|
|
22
|
+
notify(msg: Message): Promise<void>;
|
|
23
|
+
spawn(target: Spawnable): Promise<string>;
|
|
24
|
+
fork<T>(t: Forkable<T>): Promise<T>;
|
|
25
|
+
tell<M>(addr: Address, msg: M): Promise<void>;
|
|
26
|
+
raise(err: Err): Promise<void>;
|
|
27
|
+
kill(addr: Address): Promise<void>;
|
|
28
|
+
exit(): Promise<void>;
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
stop(): Promise<void>;
|
|
31
|
+
receive<T>(cases?: Case<T>[]): Promise<T>;
|
|
32
|
+
watch<T>(task: () => Promise<T>): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Mutable actors can change their behaviour after message processing.
|
|
36
|
+
*/
|
|
37
|
+
export declare abstract class Mutable extends BaseLocal {
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
run(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Immutable is an actor whose behaviour does not change when a message is
|
|
43
|
+
* received.
|
|
44
|
+
*
|
|
45
|
+
* For each message received, the same set of TypeCase classes are applied.
|
|
46
|
+
* This class is useful for simple request/response style actors that do
|
|
47
|
+
* not require much complicated logic.
|
|
48
|
+
*
|
|
49
|
+
* @typeparam T - The type of messages the actor is interested in receiving.
|
|
50
|
+
*/
|
|
51
|
+
export declare abstract class Immutable extends BaseLocal {
|
|
52
|
+
/**
|
|
53
|
+
* selectors provides the list of TypeCase classes that will be applied to
|
|
54
|
+
* all incoming messages.
|
|
55
|
+
*/
|
|
56
|
+
selectors(): Case<Promise<void> | void>[];
|
|
57
|
+
run(): Promise<void>;
|
|
58
|
+
start(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fork is a short lived actor spawned primarily for the result of its run()
|
|
62
|
+
* method.
|
|
63
|
+
*
|
|
64
|
+
* These actors can communicate with the rest of the system if needed but
|
|
65
|
+
* should limit communication with the parent as much as possible to the
|
|
66
|
+
* final result.
|
|
67
|
+
*
|
|
68
|
+
* A Fork is like an Immutable except it does not automatically start
|
|
69
|
+
* receiving messages on start. This must be manually triggered using
|
|
70
|
+
* receiveUntil() or just receive() if Mutable like behaviour is preferred.
|
|
71
|
+
*/
|
|
72
|
+
export declare abstract class Fork<T> extends BaseLocal implements Runnable<T> {
|
|
73
|
+
selectors<M>(): Case<Promise<M> | M>[];
|
|
74
|
+
/**
|
|
75
|
+
* receiveUntil uses the internal selctors define to keep processing
|
|
76
|
+
* incomming messages until the conditions of the predicate function
|
|
77
|
+
* are met.
|
|
78
|
+
*
|
|
79
|
+
* Use this to block the actor until it is ready to return a value.s
|
|
80
|
+
*/
|
|
81
|
+
receiveUntil<M>(f: MessagePredicate): Promise<M>;
|
|
82
|
+
abstract run(): Promise<T>;
|
|
83
|
+
start(): Promise<void>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Fork = exports.Immutable = exports.Mutable = exports.BaseLocal = exports.Default = exports.TypeCase = void 0;
|
|
4
|
+
var case_1 = require("@quenk/noni/lib/control/match/case");
|
|
5
|
+
Object.defineProperty(exports, "TypeCase", { enumerable: true, get: function () { return case_1.TypeCase; } });
|
|
6
|
+
Object.defineProperty(exports, "Default", { enumerable: true, get: function () { return case_1.Default; } });
|
|
7
|
+
/**
|
|
8
|
+
* BaseLocal is a base implementation of a Local actor.
|
|
9
|
+
*/
|
|
10
|
+
class BaseLocal {
|
|
11
|
+
constructor(runtime) {
|
|
12
|
+
this.runtime = runtime;
|
|
13
|
+
this.self = this.runtime.self;
|
|
14
|
+
}
|
|
15
|
+
async notify(msg) {
|
|
16
|
+
await this.runtime.notify(msg);
|
|
17
|
+
}
|
|
18
|
+
spawn(target) {
|
|
19
|
+
return this.runtime.spawn(target);
|
|
20
|
+
}
|
|
21
|
+
fork(t) {
|
|
22
|
+
return this.runtime.fork(t);
|
|
23
|
+
}
|
|
24
|
+
async tell(addr, msg) {
|
|
25
|
+
await this.runtime.tell(addr, msg);
|
|
26
|
+
}
|
|
27
|
+
async raise(err) {
|
|
28
|
+
await this.runtime.raise(err);
|
|
29
|
+
}
|
|
30
|
+
async kill(addr) {
|
|
31
|
+
await this.runtime.kill(addr);
|
|
32
|
+
}
|
|
33
|
+
async exit() {
|
|
34
|
+
await this.runtime.kill(this.self);
|
|
35
|
+
}
|
|
36
|
+
async start() { }
|
|
37
|
+
async stop() { }
|
|
38
|
+
async receive(cases = []) {
|
|
39
|
+
return this.runtime.receive(cases);
|
|
40
|
+
}
|
|
41
|
+
watch(task) {
|
|
42
|
+
return this.runtime.watch(task);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.BaseLocal = BaseLocal;
|
|
46
|
+
/**
|
|
47
|
+
* Mutable actors can change their behaviour after message processing.
|
|
48
|
+
*/
|
|
49
|
+
class Mutable extends BaseLocal {
|
|
50
|
+
async start() {
|
|
51
|
+
return this.run();
|
|
52
|
+
}
|
|
53
|
+
async run() { }
|
|
54
|
+
}
|
|
55
|
+
exports.Mutable = Mutable;
|
|
56
|
+
/**
|
|
57
|
+
* Immutable is an actor whose behaviour does not change when a message is
|
|
58
|
+
* received.
|
|
59
|
+
*
|
|
60
|
+
* For each message received, the same set of TypeCase classes are applied.
|
|
61
|
+
* This class is useful for simple request/response style actors that do
|
|
62
|
+
* not require much complicated logic.
|
|
63
|
+
*
|
|
64
|
+
* @typeparam T - The type of messages the actor is interested in receiving.
|
|
65
|
+
*/
|
|
66
|
+
class Immutable extends BaseLocal {
|
|
67
|
+
/**
|
|
68
|
+
* selectors provides the list of TypeCase classes that will be applied to
|
|
69
|
+
* all incoming messages.
|
|
70
|
+
*/
|
|
71
|
+
selectors() {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
async run() { }
|
|
75
|
+
async start() {
|
|
76
|
+
await this.run();
|
|
77
|
+
while (this.runtime.isValid())
|
|
78
|
+
await this.receive(this.selectors());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Immutable = Immutable;
|
|
82
|
+
/**
|
|
83
|
+
* Fork is a short lived actor spawned primarily for the result of its run()
|
|
84
|
+
* method.
|
|
85
|
+
*
|
|
86
|
+
* These actors can communicate with the rest of the system if needed but
|
|
87
|
+
* should limit communication with the parent as much as possible to the
|
|
88
|
+
* final result.
|
|
89
|
+
*
|
|
90
|
+
* A Fork is like an Immutable except it does not automatically start
|
|
91
|
+
* receiving messages on start. This must be manually triggered using
|
|
92
|
+
* receiveUntil() or just receive() if Mutable like behaviour is preferred.
|
|
93
|
+
*/
|
|
94
|
+
class Fork extends BaseLocal {
|
|
95
|
+
selectors() {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* receiveUntil uses the internal selctors define to keep processing
|
|
100
|
+
* incomming messages until the conditions of the predicate function
|
|
101
|
+
* are met.
|
|
102
|
+
*
|
|
103
|
+
* Use this to block the actor until it is ready to return a value.s
|
|
104
|
+
*/
|
|
105
|
+
async receiveUntil(f) {
|
|
106
|
+
return this.runtime.receiveUntil(this.selectors(), f);
|
|
107
|
+
}
|
|
108
|
+
async start() {
|
|
109
|
+
this.runtime.finalValue = await this.run();
|
|
110
|
+
this.exit();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.Fork = Fork;
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actor/local/index.ts"],"names":[],"mappings":";;;AASA,2DAAuE;AAA9D,gGAAA,QAAQ,OAAA;AAAE,+FAAA,OAAO,OAAA;AAQ1B;;GAEG;AACH,MAAsB,SAAS;IAC3B,YAAmB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAEnC,SAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAFa,CAAC;IAIvC,KAAK,CAAC,MAAM,CAAC,GAAY;QACrB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAiB;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAI,CAAc;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,IAAa,EAAE,GAAM;QAC/B,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,GAAQ;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC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AAC,YAAY,CAAI,CAAmB;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAID,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;CACJ;AAtBD,oBAsBC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
2
|
+
import { Address } from './address';
|
|
3
|
+
/**
|
|
4
|
+
* init should be called as early as possible in the child process if using the
|
|
5
|
+
* direct API (Process).
|
|
6
|
+
*
|
|
7
|
+
* It sets up a listener for incoming messages to the child_process that can
|
|
8
|
+
* be read later via receive() or select().
|
|
9
|
+
*/
|
|
10
|
+
export declare const init: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* self provides the address for this child actor.
|
|
13
|
+
*/
|
|
14
|
+
export declare const self: string;
|
|
15
|
+
/**
|
|
16
|
+
* tell sends a message to another actor in the system using the VM in the
|
|
17
|
+
* parent process.
|
|
18
|
+
*/
|
|
19
|
+
export declare const tell: <M>(to: Address, message: M) => any;
|
|
20
|
+
/**
|
|
21
|
+
* receive the next message in the message queue.
|
|
22
|
+
*
|
|
23
|
+
* TODO: drop messages that do not match any cases.
|
|
24
|
+
*/
|
|
25
|
+
export declare const receive: <T>(cases?: Case<T>[]) => Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* exit the actor, ending the process as a result.
|
|
28
|
+
*
|
|
29
|
+
* This is simply a wrapper around process.exit();
|
|
30
|
+
*/
|
|
31
|
+
export declare const exit: () => never;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exit = exports.receive = exports.tell = exports.self = exports.init = void 0;
|
|
4
|
+
const array_1 = require("@quenk/noni/lib/data/array");
|
|
5
|
+
const case_1 = require("@quenk/noni/lib/control/match/case");
|
|
6
|
+
const function_1 = require("@quenk/noni/lib/data/function");
|
|
7
|
+
const address_1 = require("./address");
|
|
8
|
+
const messages = [];
|
|
9
|
+
/**
|
|
10
|
+
* init should be called as early as possible in the child process if using the
|
|
11
|
+
* direct API (Process).
|
|
12
|
+
*
|
|
13
|
+
* It sets up a listener for incoming messages to the child_process that can
|
|
14
|
+
* be read later via receive() or select().
|
|
15
|
+
*/
|
|
16
|
+
const init = () => {
|
|
17
|
+
if (!process.send)
|
|
18
|
+
throw new Error('process: direct API is meant to ' + 'be used in a child process!');
|
|
19
|
+
process.on('message', (m) => {
|
|
20
|
+
messages.unshift(m);
|
|
21
|
+
drain();
|
|
22
|
+
});
|
|
23
|
+
process.on('uncaughtExceptionMonitor', err => process.send(err));
|
|
24
|
+
};
|
|
25
|
+
exports.init = init;
|
|
26
|
+
/**
|
|
27
|
+
* self provides the address for this child actor.
|
|
28
|
+
*/
|
|
29
|
+
exports.self = process.env.POTOO_ACTOR_ADDRESS || address_1.ADDRESS_DISCARD;
|
|
30
|
+
/**
|
|
31
|
+
* tell sends a message to another actor in the system using the VM in the
|
|
32
|
+
* parent process.
|
|
33
|
+
*/
|
|
34
|
+
const tell = (to, message) => process.send({ from: exports.self, to, message });
|
|
35
|
+
exports.tell = tell;
|
|
36
|
+
const receivers = [];
|
|
37
|
+
const defaultCases = [new case_1.Default(function_1.identity)];
|
|
38
|
+
/**
|
|
39
|
+
* receive the next message in the message queue.
|
|
40
|
+
*
|
|
41
|
+
* TODO: drop messages that do not match any cases.
|
|
42
|
+
*/
|
|
43
|
+
const receive = async (cases = defaultCases) => new Promise(resolve => {
|
|
44
|
+
let matcher = new case_1.CaseFunction(cases || defaultCases);
|
|
45
|
+
let receiver = async (msg) => {
|
|
46
|
+
if (matcher.test(msg)) {
|
|
47
|
+
resolve(await matcher.apply(msg));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
receivers.push(receiver);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
receivers.push(receiver);
|
|
54
|
+
drain();
|
|
55
|
+
});
|
|
56
|
+
exports.receive = receive;
|
|
57
|
+
const drain = () => {
|
|
58
|
+
if (!(0, array_1.empty)(messages) && !(0, array_1.empty)(receivers))
|
|
59
|
+
receivers.pop()(messages.shift());
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* exit the actor, ending the process as a result.
|
|
63
|
+
*
|
|
64
|
+
* This is simply a wrapper around process.exit();
|
|
65
|
+
*/
|
|
66
|
+
const exit = () => process.exit();
|
|
67
|
+
exports.exit = exit;
|
|
68
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/actor/process.ts"],"names":[],"mappings":";;;AACA,sDAAmD;AACnD,6DAI4C;AAC5C,4DAAyD;AAEzD,uCAAqD;AAGrD,MAAM,QAAQ,GAAc,EAAE,CAAC;AAE/B;;;;;;GAMG;AACI,MAAM,IAAI,GAAG,GAAG,EAAE;IACrB,IAAI,CAAC,OAAO,CAAC,IAAI;QACb,MAAM,IAAI,KAAK,CACX,kCAAkC,GAAG,6BAA6B,CACrE,CAAC;IAEN,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAU,EAAE,EAAE;QACjC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACpB,KAAK,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,CAAC,EAAE,CAC9B,OAAO,CAAC,IAAK,CAAC,GAAG,CAAC,CAChC,CAAC;AACN,CAAC,CAAC;AAdW,QAAA,IAAI,QAcf;AAEF;;GAEG;AACU,QAAA,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,yBAAe,CAAC;AAE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AI,QAAwB"}
|
|
@@ -85,7 +85,9 @@ class EventDispatcher {
|
|
|
85
85
|
reject(new Error(`[${thread.address}]: ERR_MONITOR_ACTOR_STOPPED`));
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
if
|
|
88
|
+
// listen for the stop event if the target is not one of the EOL
|
|
89
|
+
// events.
|
|
90
|
+
if ((type !== events.EVENT_ACTOR_STOPPED) && (type !== events.EVENT_ACTOR_DEALLOCATED))
|
|
89
91
|
this.addListener(thread.address, events.EVENT_ACTOR_STOPPED, handler);
|
|
90
92
|
this.addListener(thread.address, type, handler);
|
|
91
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../../../src/actor/system/vm/event/dispatcher.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,oDAA2D;AAQ3D,MAAM,QAAQ,GAAG;IACb,OAAO,EAAE,IAAI,GAAG,CAAC;QACb,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QACpD,CAAC,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,mBAAmB,CAAC;QAC3D,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,kBAAkB,CAAC;QACxD,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,gBAAgB,CAAC;KAC1D,CAAC;IACF,KAAK,EAAE,IAAI,GAAG,CAAC;QACX,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,mBAAmB,CAAC;QAC1D,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACtD,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACtD,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACtD,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,qBAAqB,CAAC;KAC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CAAC,GAAG,CAAC,wBAAgB,CAAC,0CAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC;SAC9D,CAAC;QACF,KAAK,IAAI,QAAQ,IAAI,SAAS;YAAE,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;CACJ;AAhHD,0CAgHC"}
|
|
@@ -109,6 +109,7 @@ export declare class PVM implements VM {
|
|
|
109
109
|
tell(to: Address, msg: Message): Promise<void>;
|
|
110
110
|
raise(err: Err): Promise<void>;
|
|
111
111
|
kill(addr: Address): Promise<void>;
|
|
112
|
+
exit(): Promise<void>;
|
|
112
113
|
receive<T>(): Promise<T>;
|
|
113
114
|
sendMessage(from: Thread, to: Address, msg: Message): Promise<void>;
|
|
114
115
|
sendKillSignal(src: Thread, target: Address): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actor/system/vm/index.ts"],"names":[],"mappings":";;;AACA,0CAA0C;AAC1C,kCAAkC;AAGlC,iEAA8D;AAC9D,sDAAyD;AACzD,wDAAoD;AAEpD,2CAMuB;AACvB,6CAA+C;AAE/C,yCAA+C;AAC/C,4CAA0E;AAE1E,mCAAmC;AACnC,2CAAwC;AAGxC,yCAAsD;AACtD,mDAAqD;AACrD,4CAA+C;AAE/C,+BAAwC;AACxC,kDAAqD;AA4ErD;;;;;;;GAOG;AACH,MAAa,GAAG;IACZ,YACW,YAAuB,IAAI,kBAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EACnD,YAAuB,IAAI,qBAAS,EAAE,EACtC,YAA6B,IAAI,2BAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAC5D,SAAwB,IAAI,+BAAuB,CAAC,SAAS,CAAC,EAC9D,MAAmB,IAAI,kBAAS,CAAC,OAAO,CAAC,EACzC,SAAS,IAAI,4BAAe,CAAC,GAAG,CAAC,EACjC,SAAuB,IAAI,qBAAY,CA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C,MAAM,CAAC,CAAC;QAErD,IAAI,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC;YAC5B,OAAO;QACX,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,IAAyB;QAC7C,OAAO,eAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AA/ID,kBA+IC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
2
|
+
import { Type } from '@quenk/noni/lib/data/type';
|
|
3
|
+
import { Forkable } from '../../../actor/template';
|
|
1
4
|
import { Api } from '../../api';
|
|
2
|
-
import { Actor } from '../..';
|
|
5
|
+
import { Actor, Message } from '../..';
|
|
3
6
|
import { VM } from '.';
|
|
7
|
+
/**
|
|
8
|
+
* MessagePredicate is a function that tests whether a message satisfies a certain
|
|
9
|
+
* condition.
|
|
10
|
+
*/
|
|
11
|
+
export type MessagePredicate = (msg: Message) => boolean | Case<Message>;
|
|
4
12
|
/**
|
|
5
13
|
* Runtime is the interface used by the outside world (JS) to execute code
|
|
6
14
|
* in the VM.
|
|
@@ -10,6 +18,13 @@ export interface Runtime extends Actor, Api {
|
|
|
10
18
|
* vm the Runtime belongs to.
|
|
11
19
|
*/
|
|
12
20
|
vm: VM;
|
|
21
|
+
/**
|
|
22
|
+
* finalValue of the Runtime.
|
|
23
|
+
*
|
|
24
|
+
* This can be set so that the parent of the Runtime obtains a result
|
|
25
|
+
* if the child has been forked instead of spawned.
|
|
26
|
+
*/
|
|
27
|
+
finalValue?: Type;
|
|
13
28
|
/**
|
|
14
29
|
* isValid indicates whether the Runtime is still valid.
|
|
15
30
|
*
|
|
@@ -17,6 +32,22 @@ export interface Runtime extends Actor, Api {
|
|
|
17
32
|
* part of the system.
|
|
18
33
|
*/
|
|
19
34
|
isValid(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* fork is like spawn but meant for returning the result of a child
|
|
37
|
+
* actor instead of an address.
|
|
38
|
+
*
|
|
39
|
+
* The child actor only provides the result upon its exit.
|
|
40
|
+
*/
|
|
41
|
+
fork<T>(t: Forkable<T>): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* receiveUntil continues invoking receive() until the result satisfies
|
|
44
|
+
* the test function provided.
|
|
45
|
+
*
|
|
46
|
+
* Note that the function is applied to the result of case matching it
|
|
47
|
+
* is therefore important to return a value in at least one of the cases
|
|
48
|
+
* to the predicate can be satisfied.
|
|
49
|
+
*/
|
|
50
|
+
receiveUntil<T>(cases: Case<T>[], f: MessagePredicate): Promise<T>;
|
|
20
51
|
/**
|
|
21
52
|
* watch an asynchronous task, feeding any errors into the VM's
|
|
22
53
|
* error handling machinery.
|
|
@@ -5,8 +5,8 @@ import { Thread } from '.';
|
|
|
5
5
|
* ThreadCollector is used to automatically deallocate dead threads from the
|
|
6
6
|
* system.
|
|
7
7
|
*
|
|
8
|
-
* This applies to function actors which are deallocated automatically after
|
|
9
|
-
*
|
|
8
|
+
* This applies to function actors which are deallocated automatically after
|
|
9
|
+
* they execute. However, this deallocation is delayed until all child threads
|
|
10
10
|
* have also been deallocated for the actor.
|
|
11
11
|
*/
|
|
12
12
|
export declare class ThreadCollector {
|
|
@@ -8,8 +8,8 @@ const shared_1 = require("./shared");
|
|
|
8
8
|
* ThreadCollector is used to automatically deallocate dead threads from the
|
|
9
9
|
* system.
|
|
10
10
|
*
|
|
11
|
-
* This applies to function actors which are deallocated automatically after
|
|
12
|
-
*
|
|
11
|
+
* This applies to function actors which are deallocated automatically after
|
|
12
|
+
* they execute. However, this deallocation is delayed until all child threads
|
|
13
13
|
* have also been deallocated for the actor.
|
|
14
14
|
*/
|
|
15
15
|
class ThreadCollector {
|
|
@@ -50,7 +50,12 @@ class ThreadRunner {
|
|
|
50
50
|
let { events, collector } = (0, lazy_1.evaluate)(this.vm);
|
|
51
51
|
if (thread.template.run)
|
|
52
52
|
collector.mark(thread);
|
|
53
|
-
|
|
53
|
+
try {
|
|
54
|
+
await thread.start();
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
await thread.raise(e);
|
|
58
|
+
}
|
|
54
59
|
await events.dispatchActorEvent(thread.address, thread.address, event_1.EVENT_ACTOR_STARTED);
|
|
55
60
|
await collector.collect(thread);
|
|
56
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../src/actor/system/vm/thread/runner.ts"],"names":[],"mappings":";;;AAAA,oDAA2D;AAG3D,gDAO2B;AAC3B,oCAOkB;AAIlB,MAAM,YAAY,GAAG,CAAC,6BAAqB,EAAE,+BAAuB,CAAC,CAAC;AAEtE,MAAM,aAAa,GAAsB;IACrC,CAAC,kCAAuB,CAAC,EAAE,6BAAqB;IAChD,CAAC,gCAAqB,CAAC,EAAE,2BAAmB;IAC5C,CAAC,kCAAuB,CAAC,EAAE,2BAAmB;IAC9C,CAAC,gCAAqB,CAAC,EAAE,2BAAmB;CAC/C,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAwB,EAAE,EAAE,WACpD,OAAA,MAAA,aAAa,CAAC,KAAK,CAAC,mCAAI,6BAAqB,CAAA,EAAA,CAAC;AAElD;;;GAGG;AACH,MAAa,YAAY;IACrB,YAAmB,EAAY;QAAZ,OAAE,GAAF,EAAE,CAAU;IAAG,CAAC;IAEnC;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAChB,MAAc,EACd,KAAa,EACb,QAA2B,kCAAuB;QAElD,IAAI,EAAE,MAAM,EAAE,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;Q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uB;QAElD,IAAI,EAAE,MAAM,EAAE,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAEpC,sEAAsE;QACtE,mEAAmE;QACnE,OAAO,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;YAC7B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,SAAS,CAAC,MAAc;QAC1B,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE9C,IAAwB,MAAM,CAAC,QAAS,CAAC,GAAG;YAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErE,IAAI,CAAC;YACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,CAAQ,CAAC,CAAC,CAAC;QACjC,CAAC;QAED,MAAM,MAAM,CAAC,kBAAkB,CAC3B,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,OAAO,EACd,2BAAmB,CACtB,CAAC;QAEF,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ;AAtDD,oCAsDC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Err } from '@quenk/noni/lib/control/error';
|
|
2
2
|
import { Case } from '@quenk/noni/lib/control/match/case';
|
|
3
|
+
import { Type } from '@quenk/noni/lib/data/type';
|
|
3
4
|
import { Maybe } from '@quenk/noni/lib/data/maybe';
|
|
4
5
|
import { SharedTemplate, Spawnable } from '../../../../template';
|
|
5
6
|
import { Address } from '../../../../address';
|
|
@@ -17,7 +18,8 @@ export declare class JSThread implements SharedThread {
|
|
|
17
18
|
mailbox: Message[];
|
|
18
19
|
state: ThreadState;
|
|
19
20
|
actor: Maybe<Actor>;
|
|
20
|
-
|
|
21
|
+
finalValue?: Type | undefined;
|
|
22
|
+
constructor(vm: VM, template: SharedTemplate, address: Address, mailbox?: Message[], state?: ThreadState, actor?: Maybe<Actor>, finalValue?: Type | undefined);
|
|
21
23
|
readonly self: string;
|
|
22
24
|
_assertValid(): void;
|
|
23
25
|
isValid(): boolean;
|
|
@@ -25,6 +27,7 @@ export declare class JSThread implements SharedThread {
|
|
|
25
27
|
notify(msg: Message): Promise<void>;
|
|
26
28
|
stop(): Promise<void>;
|
|
27
29
|
watch<T>(task: () => Promise<T> | Promise<T>): Promise<void>;
|
|
30
|
+
exit(): Promise<void>;
|
|
28
31
|
kill(address: Address): Promise<void>;
|
|
29
32
|
die(): void;
|
|
30
33
|
/**
|
|
@@ -33,6 +36,11 @@ export declare class JSThread implements SharedThread {
|
|
|
33
36
|
resume(): void;
|
|
34
37
|
raise(e: Err): Promise<void>;
|
|
35
38
|
spawn(tmpl: Spawnable): Promise<Address>;
|
|
39
|
+
/**
|
|
40
|
+
* TODO: move to allocator
|
|
41
|
+
*/
|
|
42
|
+
fork<T>(tmpl: Spawnable): Promise<T>;
|
|
36
43
|
tell(addr: Address, msg: Message): Promise<void>;
|
|
37
|
-
receive<T
|
|
44
|
+
receive<T>(cases?: Case<T>[]): Promise<T>;
|
|
45
|
+
receiveUntil<T = Message>(cases: Case<T>[], f: (m: Message) => boolean): Promise<T>;
|
|
38
46
|
}
|
|
@@ -18,13 +18,14 @@ exports.ERR_THREAD_INVALID = 'ERR_THREAD_INVALID';
|
|
|
18
18
|
* JSThread is used by actors that run in the same event loop as the VM.
|
|
19
19
|
*/
|
|
20
20
|
class JSThread {
|
|
21
|
-
constructor(vm, template, address, mailbox = [], state = _1.ThreadState.IDLE, actor = maybe_1.Maybe.nothing()) {
|
|
21
|
+
constructor(vm, template, address, mailbox = [], state = _1.ThreadState.IDLE, actor = maybe_1.Maybe.nothing(), finalValue) {
|
|
22
22
|
this.vm = vm;
|
|
23
23
|
this.template = template;
|
|
24
24
|
this.address = address;
|
|
25
25
|
this.mailbox = mailbox;
|
|
26
26
|
this.state = state;
|
|
27
27
|
this.actor = actor;
|
|
28
|
+
this.finalValue = finalValue;
|
|
28
29
|
this.self = this.address;
|
|
29
30
|
}
|
|
30
31
|
_assertValid() {
|
|
@@ -62,6 +63,9 @@ class JSThread {
|
|
|
62
63
|
this._assertValid();
|
|
63
64
|
await ((0, type_1.isFunction)(task) ? future_1.Future.do(task) : task).catch(err => this.raise(err));
|
|
64
65
|
}
|
|
66
|
+
async exit() {
|
|
67
|
+
await this.kill(this.self);
|
|
68
|
+
}
|
|
65
69
|
async kill(address) {
|
|
66
70
|
this._assertValid();
|
|
67
71
|
if (address === this.self)
|
|
@@ -95,6 +99,21 @@ class JSThread {
|
|
|
95
99
|
});
|
|
96
100
|
return result;
|
|
97
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* TODO: move to allocator
|
|
104
|
+
*/
|
|
105
|
+
async fork(tmpl) {
|
|
106
|
+
this._assertValid();
|
|
107
|
+
// Ensure we do not wait until the child dies.
|
|
108
|
+
let addr = await this.spawn(Object.assign(Object.assign({}, (0, template_1.fromSpawnable)(tmpl)), { spawnConcern: template_1.SPAWN_CONCERN_ALLOCATED }));
|
|
109
|
+
let mthread = this.vm.allocator.getThread(addr);
|
|
110
|
+
if (mthread.isNothing()) {
|
|
111
|
+
throw new Error(`Failed to find thread with address ${addr}`);
|
|
112
|
+
}
|
|
113
|
+
let thread = mthread.get();
|
|
114
|
+
await this.vm.events.monitor(thread, event_1.EVENT_ACTOR_DEALLOCATED);
|
|
115
|
+
return thread.finalValue;
|
|
116
|
+
}
|
|
98
117
|
async tell(addr, msg) {
|
|
99
118
|
this._assertValid();
|
|
100
119
|
await future_1.Future.fromCallback(cb => {
|
|
@@ -130,6 +149,14 @@ class JSThread {
|
|
|
130
149
|
});
|
|
131
150
|
return msg;
|
|
132
151
|
}
|
|
152
|
+
async receiveUntil(cases, f) {
|
|
153
|
+
this._assertValid();
|
|
154
|
+
while (true) {
|
|
155
|
+
let msg = await this.receive(cases);
|
|
156
|
+
if (f(msg))
|
|
157
|
+
return msg;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
133
160
|
}
|
|
134
161
|
exports.JSThread = JSThread;
|
|
135
162
|
//# sourceMappingURL=js.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js.js","sourceRoot":"","sources":["../../../../../../src/actor/system/vm/thread/shared/js.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAC9D,sDAAmD;AACnD,6DAI4C;AAC5C,4DAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"js.js","sourceRoot":"","sources":["../../../../../../src/actor/system/vm/thread/shared/js.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAC9D,sDAAmD;AACnD,6DAI4C;AAC5C,4DAAyD;AACzD,oDAA6D;AAC7D,sDAAmD;AAEnD,mDAO8B;AAC9B,iDAA+D;AAC/D,+CAKyB;AAGzB,wBAA8C;AAC9C,uCAMqB;AAErB,MAAM,YAAY,GAAG,CAAC,IAAI,cAAO,CAAC,mBAAQ,CAAC,CAAC,CAAC;AAEhC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD;;GAEG;AACH,MAAa,QAAQ;IACjB,YACW,EAAM,EACN,QAAwB,EACxB,OAAgB,EAChB,UAAqB,EAAE,EACvB,QAAqB,cAAW,CAAC,IAAI,EACrC,QAAsB,aAAK,CAAC,OAAO,EAAE,EACrC,UAAiB;QANjB,OAAE,GAAF,EAAE,CAAI;QACN,aAAQ,GAAR,QAAQ,CAAgB;QACxB,YAAO,GAAP,OAAO,CAAS;QAChB,YAAO,GAAP,OAAO,CAAgB;QACvB,UAAK,GAAL,KAAK,CAAgC;QACrC,UAAK,GAA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ni/lib/data/record/path';
|
|
2
2
|
import { Err } from '@quenk/noni/lib/control/error';
|
|
3
3
|
import { Runtime } from './system/vm/runtime';
|
|
4
|
-
import { Actor } from './';
|
|
4
|
+
import { Actor, Runnable } from './';
|
|
5
5
|
export declare const ACTION_RAISE = -1;
|
|
6
6
|
export declare const ACTION_IGNORE = 0;
|
|
7
7
|
export declare const ACTION_RESTART = 1;
|
|
@@ -87,6 +87,11 @@ export type CreateFunc = (runtime: Runtime) => Actor;
|
|
|
87
87
|
* not just a function that returns a Promise.
|
|
88
88
|
*/
|
|
89
89
|
export type RunFunc = (runtime: Runtime) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* CreateForkFunc is a function that creates a forked actor given the handle
|
|
92
|
+
* the system has generated.
|
|
93
|
+
*/
|
|
94
|
+
export type CreateForkFunc<T> = (runtime: Runtime) => Runnable<T>;
|
|
90
95
|
/**
|
|
91
96
|
* Template is an object that tells the system how to create an manage an
|
|
92
97
|
* actor.
|
|
@@ -129,6 +134,13 @@ export interface ProcessTemplate extends BaseTemplate {
|
|
|
129
134
|
*/
|
|
130
135
|
script: Path;
|
|
131
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* ForkTemplate is used for creating forked actors.
|
|
139
|
+
*/
|
|
140
|
+
export interface ForkTemplate<T> extends BaseTemplate {
|
|
141
|
+
create: CreateForkFunc<T>;
|
|
142
|
+
}
|
|
143
|
+
export type Forkable<T> = ForkTemplate<T>;
|
|
132
144
|
/**
|
|
133
145
|
* Spawnable allows a CreateFunc to be used in place of a Template.
|
|
134
146
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/actor/template.ts"],"names":[],"mappings":";;;AAEA,oDAAiE;AAKpD,QAAA,YAAY,GAAG,CAAC,GAAG,CAAC;AACpB,QAAA,aAAa,GAAG,GAAG,CAAC;AACpB,QAAA,cAAc,GAAG,GAAG,CAAC;AACrB,QAAA,WAAW,GAAG,GAAG,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