Rename "network" to "dataspace" throughout
This commit is contained in:
parent
71a7bacccd
commit
7fcfa9586b
|
@ -60,7 +60,7 @@
|
||||||
(advertisement (tcp-channel us them ?) #:meta-level 1) ;; we will write to remote client
|
(advertisement (tcp-channel us them ?) #:meta-level 1) ;; we will write to remote client
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
#:meta-level 1
|
#:meta-level 1
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
(subscription (advertise (tcp-channel them us ?)) #:meta-level 1)
|
(subscription (advertise (tcp-channel them us ?)) #:meta-level 1)
|
||||||
(advertisement (tcp-channel us them ?) #:meta-level 1)))))
|
(advertisement (tcp-channel us them ?) #:meta-level 1)))))
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e counter)
|
(spawn (lambda (e counter)
|
||||||
(match e
|
(match e
|
||||||
[(message 'bump)
|
[(message 'bump)
|
||||||
|
|
|
@ -896,18 +896,18 @@
|
||||||
;; LevelTerminationMonitor
|
;; LevelTerminationMonitor
|
||||||
;;
|
;;
|
||||||
;; When the player vanishes from the board, or LevelCompleted is seen,
|
;; When the player vanishes from the board, or LevelCompleted is seen,
|
||||||
;; kills the network.
|
;; kills the dataspace.
|
||||||
|
|
||||||
(define (spawn-level-termination-monitor)
|
(define (spawn-level-termination-monitor)
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
[(? patch/removed?)
|
[(? patch/removed?)
|
||||||
(log-info "Player died! Terminating level.")
|
(log-info "Player died! Terminating level.")
|
||||||
(transition s (quit-network))]
|
(transition s (quit-dataspace))]
|
||||||
[(message (at-meta (level-completed)))
|
[(message (at-meta (level-completed)))
|
||||||
(log-info "Level completed! Terminating level.")
|
(log-info "Level completed! Terminating level.")
|
||||||
(transition s (list (message (at-meta (add-to-score 100)))
|
(transition s (list (message (at-meta (add-to-score 100)))
|
||||||
(quit-network)))]
|
(quit-dataspace)))]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
(void)
|
(void)
|
||||||
(patch-seq (sub (game-piece-configuration player-id ? ? ?))
|
(patch-seq (sub (game-piece-configuration player-id ? ? ?))
|
||||||
|
@ -946,7 +946,7 @@
|
||||||
#:level-size [level-size-vec (vector 4000 2000)]
|
#:level-size [level-size-vec (vector 4000 2000)]
|
||||||
#:scene [scene grassland-backdrop]
|
#:scene [scene grassland-backdrop]
|
||||||
. actions)
|
. actions)
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(and scene (spawn-background-image level-size-vec scene))
|
(and scene (spawn-background-image level-size-vec scene))
|
||||||
(spawn-display-controller level-size-vec)
|
(spawn-display-controller level-size-vec)
|
||||||
(spawn-physics-engine)
|
(spawn-physics-engine)
|
||||||
|
@ -1028,10 +1028,10 @@
|
||||||
|
|
||||||
(define game-level 3) ;; used to specify meta-level to reach external I/O
|
(define game-level 3) ;; used to specify meta-level to reach external I/O
|
||||||
|
|
||||||
(2d-network #:width 600 #:height 400
|
(2d-dataspace #:width 600 #:height 400
|
||||||
(spawn-keyboard-integrator)
|
(spawn-keyboard-integrator)
|
||||||
(spawn-scene-manager)
|
(spawn-scene-manager)
|
||||||
(spawn-network (spawn-score-keeper)
|
(spawn-dataspace (spawn-score-keeper)
|
||||||
(spawn-level-spawner 0)
|
(spawn-level-spawner 0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,8 +11,8 @@ Source files in `src/`, from most general to most specific:
|
||||||
- `route.js`: Implementation of dataspace trie structure.
|
- `route.js`: Implementation of dataspace trie structure.
|
||||||
- `patch.js`: Implementation of patches over dataspace tries.
|
- `patch.js`: Implementation of patches over dataspace tries.
|
||||||
- `mux.js`: Use of tries plus patches to build a (de)multiplexing routing structure.
|
- `mux.js`: Use of tries plus patches to build a (de)multiplexing routing structure.
|
||||||
- `network.js`: Implementation of core leaf actors and networks.
|
- `dataspace.js`: Implementation of core leaf actors and dataspaces.
|
||||||
- `ground.js`: Pseudo-network acting as the global outermost context for Syndicate actors.
|
- `ground.js`: Pseudo-dataspace acting as the global outermost context for Syndicate actors.
|
||||||
|
|
||||||
- `ack.js`: Utility for detecting when a previous state change has taken effect.
|
- `ack.js`: Utility for detecting when a previous state change has taken effect.
|
||||||
- `seal.js`: Immutable container for data, used to hide structure from dataspace tries.
|
- `seal.js`: Immutable container for data, used to hide structure from dataspace tries.
|
||||||
|
|
|
@ -86,7 +86,7 @@ var modifiedSourceActions = {
|
||||||
return buildActor(ctorExp.asES5, block);
|
return buildActor(ctorExp.asES5, block);
|
||||||
},
|
},
|
||||||
|
|
||||||
NetworkStatement_ground: function(_ground, _network, maybeId, block) {
|
DataspaceStatement_ground: function(_ground, _dataspace, maybeId, block) {
|
||||||
var code = 'new Syndicate.Ground(function () ' + block.asES5 + ').startStepping();';
|
var code = 'new Syndicate.Ground(function () ' + block.asES5 + ').startStepping();';
|
||||||
if (maybeId.numChildren === 1) {
|
if (maybeId.numChildren === 1) {
|
||||||
return 'var ' + maybeId.children[0].interval.contents + ' = ' + code;
|
return 'var ' + maybeId.children[0].interval.contents + ' = ' + code;
|
||||||
|
@ -94,8 +94,8 @@ var modifiedSourceActions = {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NetworkStatement_normal: function(_network, block) {
|
DataspaceStatement_normal: function(_dataspace, block) {
|
||||||
return 'Syndicate.Network.spawn(new Network(function () ' + block.asES5 + '));';
|
return 'Syndicate.Dataspace.spawn(new Dataspace(function () ' + block.asES5 + '));';
|
||||||
},
|
},
|
||||||
|
|
||||||
ActorFacetStatement_state: function(_state, facetBlock, _until, transitionBlock) {
|
ActorFacetStatement_state: function(_state, facetBlock, _until, transitionBlock) {
|
||||||
|
@ -143,7 +143,7 @@ var modifiedSourceActions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
SendMessageStatement: function(_colons, expr, sc) {
|
SendMessageStatement: function(_colons, expr, sc) {
|
||||||
return 'Syndicate.Network.send(' + expr.asES5 + ')' + sc.interval.contents;
|
return 'Syndicate.Dataspace.send(' + expr.asES5 + ')' + sc.interval.contents;
|
||||||
},
|
},
|
||||||
|
|
||||||
FacetBlock: function(_leftParen, init, situations, done, _rightParen) {
|
FacetBlock: function(_leftParen, init, situations, done, _rightParen) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ var Syndicate = require('./src/main.js');
|
||||||
assertion type account(balance);
|
assertion type account(balance);
|
||||||
assertion type deposit(amount);
|
assertion type deposit(amount);
|
||||||
|
|
||||||
ground network {
|
ground dataspace {
|
||||||
actor {
|
actor {
|
||||||
this.balance = 0;
|
this.balance = 0;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ assertion type file(name, content) = "file";
|
||||||
assertion type saveFile(name, content) = "save";
|
assertion type saveFile(name, content) = "save";
|
||||||
assertion type deleteFile(name) = "delete";
|
assertion type deleteFile(name) = "delete";
|
||||||
|
|
||||||
ground network {
|
ground dataspace {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// The file system actor
|
// The file system actor
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ Syndicate <: ES5 {
|
||||||
|
|
||||||
Statement
|
Statement
|
||||||
+= ActorStatement
|
+= ActorStatement
|
||||||
| NetworkStatement
|
| DataspaceStatement
|
||||||
| ActorFacetStatement
|
| ActorFacetStatement
|
||||||
| AssertionTypeDeclarationStatement
|
| AssertionTypeDeclarationStatement
|
||||||
| SendMessageStatement
|
| SendMessageStatement
|
||||||
|
@ -17,9 +17,9 @@ Syndicate <: ES5 {
|
||||||
= actor CallExpression Block -- withConstructor
|
= actor CallExpression Block -- withConstructor
|
||||||
| actor Block -- noConstructor
|
| actor Block -- noConstructor
|
||||||
|
|
||||||
NetworkStatement
|
DataspaceStatement
|
||||||
= ground network identifier? Block -- ground
|
= ground dataspace identifier? Block -- ground
|
||||||
| network Block -- normal
|
| dataspace Block -- normal
|
||||||
|
|
||||||
ActorFacetStatement
|
ActorFacetStatement
|
||||||
= state FacetBlock until FacetStateTransitionBlock -- state
|
= state FacetBlock until FacetStateTransitionBlock -- state
|
||||||
|
@ -71,6 +71,7 @@ Syndicate <: ES5 {
|
||||||
assert = "assert" ~identifierPart
|
assert = "assert" ~identifierPart
|
||||||
asserted = "asserted" ~identifierPart
|
asserted = "asserted" ~identifierPart
|
||||||
assertion = "assertion" ~identifierPart
|
assertion = "assertion" ~identifierPart
|
||||||
|
dataspace = "dataspace" ~identifierPart
|
||||||
done = "done" ~identifierPart
|
done = "done" ~identifierPart
|
||||||
during = "during" ~identifierPart
|
during = "during" ~identifierPart
|
||||||
forever = "forever" ~identifierPart
|
forever = "forever" ~identifierPart
|
||||||
|
@ -78,7 +79,6 @@ Syndicate <: ES5 {
|
||||||
init = "init" ~identifierPart
|
init = "init" ~identifierPart
|
||||||
message = "message" ~identifierPart
|
message = "message" ~identifierPart
|
||||||
metalevel = "metalevel" ~identifierPart
|
metalevel = "metalevel" ~identifierPart
|
||||||
network = "network" ~identifierPart
|
|
||||||
on = "on" ~identifierPart
|
on = "on" ~identifierPart
|
||||||
retracted = "retracted" ~identifierPart
|
retracted = "retracted" ~identifierPart
|
||||||
state = "state" ~identifierPart
|
state = "state" ~identifierPart
|
||||||
|
|
|
@ -2,7 +2,7 @@ assertion type DOM(containerSelector, fragmentClass, spec);
|
||||||
assertion type jQuery(selector, eventType, event);
|
assertion type jQuery(selector, eventType, event);
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
ground network {
|
ground dataspace {
|
||||||
Syndicate.DOM.spawnDOMDriver();
|
Syndicate.DOM.spawnDOMDriver();
|
||||||
Syndicate.JQuery.spawnJQueryDriver();
|
Syndicate.JQuery.spawnJQueryDriver();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var G;
|
var G;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var Network = Syndicate.Network;
|
var Dataspace = Syndicate.Dataspace;
|
||||||
var sub = Syndicate.sub;
|
var sub = Syndicate.sub;
|
||||||
var assert = Syndicate.assert;
|
var assert = Syndicate.assert;
|
||||||
var retract = Syndicate.retract;
|
var retract = Syndicate.retract;
|
||||||
|
@ -13,7 +13,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
Syndicate.DOM.spawnDOMDriver();
|
Syndicate.DOM.spawnDOMDriver();
|
||||||
|
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () {
|
boot: function () {
|
||||||
return assert(["DOM", "#clicker-holder", "clicker",
|
return assert(["DOM", "#clicker-holder", "clicker",
|
||||||
seal(["button", ["span", [["style", "font-style: italic"]], "Click me!"]])])
|
seal(["button", ["span", [["style", "font-style: italic"]], "Click me!"]])])
|
||||||
|
@ -21,23 +21,23 @@ $(document).ready(function () {
|
||||||
},
|
},
|
||||||
handleEvent: function (e) {
|
handleEvent: function (e) {
|
||||||
if (e.type === "message" && e.message[0] === "jQuery") {
|
if (e.type === "message" && e.message[0] === "jQuery") {
|
||||||
Network.send("bump_count");
|
Dataspace.send("bump_count");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
counter: 0,
|
counter: 0,
|
||||||
boot: function () {
|
boot: function () {
|
||||||
this.updateState();
|
this.updateState();
|
||||||
return sub("bump_count");
|
return sub("bump_count");
|
||||||
},
|
},
|
||||||
updateState: function () {
|
updateState: function () {
|
||||||
Network.stateChange(retract(["DOM", __, __, __])
|
Dataspace.stateChange(retract(["DOM", __, __, __])
|
||||||
.andThen(assert(["DOM", "#counter-holder", "counter",
|
.andThen(assert(["DOM", "#counter-holder", "counter",
|
||||||
seal(["div",
|
seal(["div",
|
||||||
["p", "The current count is: ",
|
["p", "The current count is: ",
|
||||||
this.counter]])])));
|
this.counter]])])));
|
||||||
},
|
},
|
||||||
handleEvent: function (e) {
|
handleEvent: function (e) {
|
||||||
if (e.type === "message" && e.message === "bump_count") {
|
if (e.type === "message" && e.message === "bump_count") {
|
||||||
|
@ -48,7 +48,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
G.network.onStateChange = function (mux, patch) {
|
G.dataspace.onStateChange = function (mux, patch) {
|
||||||
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var G;
|
var G;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var Network = Syndicate.Network;
|
var Dataspace = Syndicate.Dataspace;
|
||||||
var sub = Syndicate.sub;
|
var sub = Syndicate.sub;
|
||||||
var __ = Syndicate.__;
|
var __ = Syndicate.__;
|
||||||
var _$ = Syndicate._$;
|
var _$ = Syndicate._$;
|
||||||
|
@ -12,7 +12,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
Syndicate.JQuery.spawnJQueryDriver();
|
Syndicate.JQuery.spawnJQueryDriver();
|
||||||
|
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () {
|
boot: function () {
|
||||||
return sub(['jQuery', '#clicker', 'click', __]);
|
return sub(['jQuery', '#clicker', 'click', __]);
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
G.network.onStateChange = function (mux, patch) {
|
G.dataspace.onStateChange = function (mux, patch) {
|
||||||
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
||||||
};
|
};
|
||||||
G.startStepping();
|
G.startStepping();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
assertion type beep(counter);
|
assertion type beep(counter);
|
||||||
|
|
||||||
ground network {
|
ground dataspace {
|
||||||
console.log('starting ground boot');
|
console.log('starting ground boot');
|
||||||
|
|
||||||
actor {
|
actor {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var G;
|
var G;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var Network = Syndicate.Network;
|
var Dataspace = Syndicate.Dataspace;
|
||||||
var sub = Syndicate.sub;
|
var sub = Syndicate.sub;
|
||||||
var __ = Syndicate.__;
|
var __ = Syndicate.__;
|
||||||
var _$ = Syndicate._$;
|
var _$ = Syndicate._$;
|
||||||
|
@ -10,17 +10,17 @@ $(document).ready(function () {
|
||||||
G = new Syndicate.Ground(function () {
|
G = new Syndicate.Ground(function () {
|
||||||
console.log('starting ground boot');
|
console.log('starting ground boot');
|
||||||
|
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
counter: 0,
|
counter: 0,
|
||||||
boot: function () {},
|
boot: function () {},
|
||||||
handleEvent: function (e) {},
|
handleEvent: function (e) {},
|
||||||
step: function () {
|
step: function () {
|
||||||
Network.send(["beep", this.counter++]);
|
Dataspace.send(["beep", this.counter++]);
|
||||||
return this.counter <= 10;
|
return this.counter <= 10;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () { return sub(["beep", __]); },
|
boot: function () { return sub(["beep", __]); },
|
||||||
handleEvent: function (e) {
|
handleEvent: function (e) {
|
||||||
if (e.type === 'message') {
|
if (e.type === 'message') {
|
||||||
|
|
|
@ -154,7 +154,7 @@ function spawnSearch() {
|
||||||
// Main
|
// Main
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
ground network G {
|
ground dataspace G {
|
||||||
Syndicate.JQuery.spawnJQueryDriver();
|
Syndicate.JQuery.spawnJQueryDriver();
|
||||||
Syndicate.DOM.spawnDOMDriver();
|
Syndicate.DOM.spawnDOMDriver();
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ $(document).ready(function () {
|
||||||
spawnSearch();
|
spawnSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
G.network.onStateChange = function (mux, patch) {
|
G.dataspace.onStateChange = function (mux, patch) {
|
||||||
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// GUI
|
// GUI
|
||||||
|
|
||||||
var Network = Syndicate.Network;
|
var Dataspace = Syndicate.Dataspace;
|
||||||
var Route = Syndicate.Route;
|
var Route = Syndicate.Route;
|
||||||
var Patch = Syndicate.Patch;
|
var Patch = Syndicate.Patch;
|
||||||
var __ = Syndicate.__;
|
var __ = Syndicate.__;
|
||||||
|
@ -26,7 +26,7 @@ function piece(text, pos, lo, hi, cls) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnGui() {
|
function spawnGui() {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
field: { text: '', pos: 0 },
|
field: { text: '', pos: 0 },
|
||||||
highlight: { state: false },
|
highlight: { state: false },
|
||||||
|
|
||||||
|
@ -46,15 +46,15 @@ function spawnGui() {
|
||||||
var keycode = event.keyCode;
|
var keycode = event.keyCode;
|
||||||
var character = String.fromCharCode(event.charCode);
|
var character = String.fromCharCode(event.charCode);
|
||||||
if (keycode === 37 /* left */) {
|
if (keycode === 37 /* left */) {
|
||||||
Network.send(["fieldCommand", "cursorLeft"]);
|
Dataspace.send(["fieldCommand", "cursorLeft"]);
|
||||||
} else if (keycode === 39 /* right */) {
|
} else if (keycode === 39 /* right */) {
|
||||||
Network.send(["fieldCommand", "cursorRight"]);
|
Dataspace.send(["fieldCommand", "cursorRight"]);
|
||||||
} else if (keycode === 9 /* tab */) {
|
} else if (keycode === 9 /* tab */) {
|
||||||
// ignore
|
// ignore
|
||||||
} else if (keycode === 8 /* backspace */) {
|
} else if (keycode === 8 /* backspace */) {
|
||||||
Network.send(["fieldCommand", "backspace"]);
|
Dataspace.send(["fieldCommand", "backspace"]);
|
||||||
} else if (character) {
|
} else if (character) {
|
||||||
Network.send(["fieldCommand", ["insert", character]]);
|
Dataspace.send(["fieldCommand", ["insert", character]]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "stateChange":
|
case "stateChange":
|
||||||
|
@ -89,7 +89,7 @@ function spawnGui() {
|
||||||
|
|
||||||
function spawnModel() {
|
function spawnModel() {
|
||||||
var initialContents = "initial";
|
var initialContents = "initial";
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
fieldContents: initialContents,
|
fieldContents: initialContents,
|
||||||
cursorPos: initialContents.length, /* positions address gaps between characters */
|
cursorPos: initialContents.length, /* positions address gaps between characters */
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ function spawnModel() {
|
||||||
},
|
},
|
||||||
|
|
||||||
publishState: function () {
|
publishState: function () {
|
||||||
Network.stateChange(
|
Dataspace.stateChange(
|
||||||
Patch.retract(["fieldContents", __, __])
|
Patch.retract(["fieldContents", __, __])
|
||||||
.andThen(Patch.assert(["fieldContents", this.fieldContents, this.cursorPos])));
|
.andThen(Patch.assert(["fieldContents", this.fieldContents, this.cursorPos])));
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ function spawnModel() {
|
||||||
// Search engine
|
// Search engine
|
||||||
|
|
||||||
function spawnSearch() {
|
function spawnSearch() {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
fieldContents: "",
|
fieldContents: "",
|
||||||
highlight: false,
|
highlight: false,
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ function spawnSearch() {
|
||||||
},
|
},
|
||||||
|
|
||||||
publishState: function () {
|
publishState: function () {
|
||||||
Network.stateChange(
|
Dataspace.stateChange(
|
||||||
Patch.retract(["highlight", __])
|
Patch.retract(["highlight", __])
|
||||||
.andThen(Patch.assert(["highlight", this.highlight])));
|
.andThen(Patch.assert(["highlight", this.highlight])));
|
||||||
},
|
},
|
||||||
|
@ -198,7 +198,7 @@ $(document).ready(function () {
|
||||||
spawnSearch();
|
spawnSearch();
|
||||||
});
|
});
|
||||||
|
|
||||||
G.network.onStateChange = function (mux, patch) {
|
G.dataspace.onStateChange = function (mux, patch) {
|
||||||
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
$("#spy-holder").text(Syndicate.prettyTrie(mux.routingTable));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Utility protocol for measuring when a stateChange takes effect.
|
// Utility protocol for measuring when a stateChange takes effect.
|
||||||
|
|
||||||
var RandomID = require('./randomid.js');
|
var RandomID = require('./randomid.js');
|
||||||
var Network = require('./network.js').Network;
|
var Dataspace = require('./dataspace.js').Dataspace;
|
||||||
var Route = require('./route.js');
|
var Route = require('./route.js');
|
||||||
var Patch = require('./patch.js');
|
var Patch = require('./patch.js');
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ function Ack(metaLevel, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ack.prototype.arm = function () {
|
Ack.prototype.arm = function () {
|
||||||
Network.stateChange(Patch.sub([$Ack, this.id], this.metaLevel));
|
Dataspace.stateChange(Patch.sub([$Ack, this.id], this.metaLevel));
|
||||||
Network.send([$Ack, this.id], this.metaLevel);
|
Dataspace.send([$Ack, this.id], this.metaLevel);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ack.prototype.disarm = function () {
|
Ack.prototype.disarm = function () {
|
||||||
Network.stateChange(Patch.unsub([$Ack, this.id], this.metaLevel));
|
Dataspace.stateChange(Patch.unsub([$Ack, this.id], this.metaLevel));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ack.prototype.check = function (e) {
|
Ack.prototype.check = function (e) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Immutable = require('immutable');
|
var Immutable = require('immutable');
|
||||||
var Network = require('./network.js').Network;
|
var Dataspace = require('./dataspace.js').Dataspace;
|
||||||
var Mux = require('./mux.js');
|
var Mux = require('./mux.js');
|
||||||
var Patch = require('./patch.js');
|
var Patch = require('./patch.js');
|
||||||
var Route = require('./route.js');
|
var Route = require('./route.js');
|
||||||
|
@ -10,7 +10,7 @@ var Util = require('./util.js');
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
function spawnActor(state, bootFn) {
|
function spawnActor(state, bootFn) {
|
||||||
Network.spawn(new Actor(state, bootFn));
|
Dataspace.spawn(new Actor(state, bootFn));
|
||||||
}
|
}
|
||||||
|
|
||||||
function Actor(state, bootFn) {
|
function Actor(state, bootFn) {
|
||||||
|
@ -41,14 +41,14 @@ Actor.prototype.removeFacet = function(facet) {
|
||||||
|
|
||||||
Actor.prototype.checkForTermination = function() {
|
Actor.prototype.checkForTermination = function() {
|
||||||
if (this.facets.isEmpty()) {
|
if (this.facets.isEmpty()) {
|
||||||
Network.exit();
|
Dataspace.exit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
function createFacet() {
|
function createFacet() {
|
||||||
return new Facet(Network.activeBehavior());
|
return new Facet(Dataspace.activeBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
function Facet(actor) {
|
function Facet(actor) {
|
||||||
|
@ -129,7 +129,7 @@ Facet.prototype.addEndpoint = function(endpoint) {
|
||||||
var patch = endpoint.subscriptionFn.call(this.actor.state);
|
var patch = endpoint.subscriptionFn.call(this.actor.state);
|
||||||
var r = this.actor.mux.addStream(patch);
|
var r = this.actor.mux.addStream(patch);
|
||||||
this.endpoints = this.endpoints.set(r.pid, endpoint);
|
this.endpoints = this.endpoints.set(r.pid, endpoint);
|
||||||
Network.stateChange(r.deltaAggregate);
|
Dataspace.stateChange(r.deltaAggregate);
|
||||||
return this; // for chaining
|
return this; // for chaining
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ Facet.prototype.refresh = function() {
|
||||||
var r = facet.actor.mux.updateStream(eid, patch);
|
var r = facet.actor.mux.updateStream(eid, patch);
|
||||||
aggregate = aggregate.andThen(r.deltaAggregate);
|
aggregate = aggregate.andThen(r.deltaAggregate);
|
||||||
});
|
});
|
||||||
Network.stateChange(aggregate);
|
Dataspace.stateChange(aggregate);
|
||||||
};
|
};
|
||||||
|
|
||||||
Facet.prototype.completeBuild = function() {
|
Facet.prototype.completeBuild = function() {
|
||||||
|
@ -168,7 +168,7 @@ Facet.prototype.terminate = function() {
|
||||||
var r = facet.actor.mux.removeStream(eid);
|
var r = facet.actor.mux.removeStream(eid);
|
||||||
aggregate = aggregate.andThen(r.deltaAggregate);
|
aggregate = aggregate.andThen(r.deltaAggregate);
|
||||||
});
|
});
|
||||||
Network.stateChange(aggregate);
|
Dataspace.stateChange(aggregate);
|
||||||
this.endpoints = Immutable.Map();
|
this.endpoints = Immutable.Map();
|
||||||
this.actor.removeFacet(this);
|
this.actor.removeFacet(this);
|
||||||
this.doneBlocks.forEach(function(b) { b.call(facet.actor.state); });
|
this.doneBlocks.forEach(function(b) { b.call(facet.actor.state); });
|
||||||
|
|
|
@ -24,14 +24,14 @@ function terminate() {
|
||||||
return { type: 'terminate' };
|
return { type: 'terminate' };
|
||||||
}
|
}
|
||||||
|
|
||||||
function terminateNetwork() {
|
function terminateDataspace() {
|
||||||
return { type: 'terminateNetwork' };
|
return { type: 'terminateDataspace' };
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Network */
|
/* Dataspace */
|
||||||
|
|
||||||
function Network(bootFn) {
|
function Dataspace(bootFn) {
|
||||||
this.pendingActions = Immutable.List(); // of [pid, Action]
|
this.pendingActions = Immutable.List(); // of [pid, Action]
|
||||||
this.processTable = Immutable.Map(); // pid -> Behavior
|
this.processTable = Immutable.Map(); // pid -> Behavior
|
||||||
this.runnablePids = Immutable.Set(); // of pid
|
this.runnablePids = Immutable.Set(); // of pid
|
||||||
|
@ -42,93 +42,93 @@ function Network(bootFn) {
|
||||||
|
|
||||||
// Class state and methods
|
// Class state and methods
|
||||||
|
|
||||||
Network.stack = Immutable.List();
|
Dataspace.stack = Immutable.List();
|
||||||
|
|
||||||
Network.current = function () {
|
Dataspace.current = function () {
|
||||||
return Network.stack.last().network;
|
return Dataspace.stack.last().dataspace;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.activePid = function () {
|
Dataspace.activePid = function () {
|
||||||
return Network.stack.last().activePid;
|
return Dataspace.stack.last().activePid;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.activeBehavior = function () {
|
Dataspace.activeBehavior = function () {
|
||||||
var entry = Network.stack.last();
|
var entry = Dataspace.stack.last();
|
||||||
var p = entry.network.processTable.get(entry.activePid);
|
var p = entry.dataspace.processTable.get(entry.activePid);
|
||||||
return p ? p.behavior : null;
|
return p ? p.behavior : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.withNetworkStack = function (stack, f) {
|
Dataspace.withDataspaceStack = function (stack, f) {
|
||||||
var oldStack = Network.stack;
|
var oldStack = Dataspace.stack;
|
||||||
Network.stack = stack;
|
Dataspace.stack = stack;
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = f();
|
result = f();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Network.stack = oldStack;
|
Dataspace.stack = oldStack;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
Network.stack = oldStack;
|
Dataspace.stack = oldStack;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.wrap = function (f) {
|
Dataspace.wrap = function (f) {
|
||||||
var savedStack = Network.stack;
|
var savedStack = Dataspace.stack;
|
||||||
return function () {
|
return function () {
|
||||||
var actuals = arguments;
|
var actuals = arguments;
|
||||||
return Network.withNetworkStack(savedStack, function () {
|
return Dataspace.withDataspaceStack(savedStack, function () {
|
||||||
var result = Network.current().asChild(Network.activePid(), function () {
|
var result = Dataspace.current().asChild(Dataspace.activePid(), function () {
|
||||||
return f.apply(null, actuals);
|
return f.apply(null, actuals);
|
||||||
});
|
});
|
||||||
Network.stack.reverse().forEach(function (entry) {
|
Dataspace.stack.reverse().forEach(function (entry) {
|
||||||
entry.network.markRunnable(entry.activePid);
|
entry.dataspace.markRunnable(entry.activePid);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.enqueueAction = function (action) {
|
Dataspace.enqueueAction = function (action) {
|
||||||
var entry = Network.stack.last();
|
var entry = Dataspace.stack.last();
|
||||||
entry.network.enqueueAction(entry.activePid, action);
|
entry.dataspace.enqueueAction(entry.activePid, action);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.send = function (body, metaLevel) {
|
Dataspace.send = function (body, metaLevel) {
|
||||||
Network.enqueueAction(message(Patch.prependAtMeta(body, metaLevel || 0)));
|
Dataspace.enqueueAction(message(Patch.prependAtMeta(body, metaLevel || 0)));
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.stateChange = function (patch) {
|
Dataspace.stateChange = function (patch) {
|
||||||
Network.enqueueAction(stateChange(patch));
|
Dataspace.enqueueAction(stateChange(patch));
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.spawn = function (behavior) {
|
Dataspace.spawn = function (behavior) {
|
||||||
Network.enqueueAction(spawn(behavior));
|
Dataspace.enqueueAction(spawn(behavior));
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.exit = function (exn) {
|
Dataspace.exit = function (exn) {
|
||||||
Network.current().kill(Network.activePid(), exn);
|
Dataspace.current().kill(Dataspace.activePid(), exn);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.exitNetwork = function () {
|
Dataspace.exitDataspace = function () {
|
||||||
Network.enqueueAction(terminateNetwork());
|
Dataspace.enqueueAction(terminateDataspace());
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.inertBehavior = {
|
Dataspace.inertBehavior = {
|
||||||
handleEvent: function (e) {}
|
handleEvent: function (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Instance methods
|
// Instance methods
|
||||||
|
|
||||||
Network.prototype.asChild = function (pid, f, omitLivenessCheck) {
|
Dataspace.prototype.asChild = function (pid, f, omitLivenessCheck) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var p = this.processTable.get(pid, null);
|
var p = this.processTable.get(pid, null);
|
||||||
if (!omitLivenessCheck && (p === null)) {
|
if (!omitLivenessCheck && (p === null)) {
|
||||||
console.warn("Network.asChild eliding invocation of dead process", pid);
|
console.warn("Dataspace.asChild eliding invocation of dead process", pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Network.withNetworkStack(
|
return Dataspace.withDataspaceStack(
|
||||||
Network.stack.push({ network: this, activePid: pid }),
|
Dataspace.stack.push({ dataspace: this, activePid: pid }),
|
||||||
function () {
|
function () {
|
||||||
try {
|
try {
|
||||||
return f(p);
|
return f(p);
|
||||||
|
@ -138,14 +138,14 @@ Network.prototype.asChild = function (pid, f, omitLivenessCheck) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.kill = function (pid, exn) {
|
Dataspace.prototype.kill = function (pid, exn) {
|
||||||
if (exn && exn.stack) {
|
if (exn && exn.stack) {
|
||||||
console.log("Process exiting", pid, exn, exn.stack);
|
console.log("Process exiting", pid, exn, exn.stack);
|
||||||
} else {
|
} else {
|
||||||
console.log("Process exiting", pid, exn);
|
console.log("Process exiting", pid, exn);
|
||||||
}
|
}
|
||||||
var p = this.processTable.get(pid);
|
var p = this.processTable.get(pid);
|
||||||
this.processTable = this.processTable.set(pid, { behavior: Network.inertBehavior });
|
this.processTable = this.processTable.set(pid, { behavior: Dataspace.inertBehavior });
|
||||||
if (p) {
|
if (p) {
|
||||||
if (p.behavior.trapexit) {
|
if (p.behavior.trapexit) {
|
||||||
this.asChild(pid, function () { return p.behavior.trapexit(exn); }, true);
|
this.asChild(pid, function () { return p.behavior.trapexit(exn); }, true);
|
||||||
|
@ -154,12 +154,12 @@ Network.prototype.kill = function (pid, exn) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.boot = function () {
|
Dataspace.prototype.boot = function () {
|
||||||
// Needed in order for a new Network to be marked as "runnable", so
|
// Needed in order for a new Dataspace to be marked as "runnable", so
|
||||||
// its initial actions get performed.
|
// its initial actions get performed.
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.handleEvent = function (e) {
|
Dataspace.prototype.handleEvent = function (e) {
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case 'stateChange':
|
case 'stateChange':
|
||||||
this.enqueueAction('meta', stateChange(e.patch.lift()));
|
this.enqueueAction('meta', stateChange(e.patch.lift()));
|
||||||
|
@ -175,17 +175,17 @@ Network.prototype.handleEvent = function (e) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.step = function () {
|
Dataspace.prototype.step = function () {
|
||||||
return this.dispatchActions()
|
return this.dispatchActions()
|
||||||
&& this.runRunnablePids()
|
&& this.runRunnablePids()
|
||||||
&& ((this.pendingActions.size > 0) || (this.runnablePids.size > 0));
|
&& ((this.pendingActions.size > 0) || (this.runnablePids.size > 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.enqueueAction = function (pid, action) {
|
Dataspace.prototype.enqueueAction = function (pid, action) {
|
||||||
this.pendingActions = this.pendingActions.push([pid, action]);
|
this.pendingActions = this.pendingActions.push([pid, action]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.dispatchActions = function () {
|
Dataspace.prototype.dispatchActions = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var actionQueue = this.pendingActions;
|
var actionQueue = this.pendingActions;
|
||||||
this.pendingActions = Immutable.List();
|
this.pendingActions = Immutable.List();
|
||||||
|
@ -201,11 +201,11 @@ Network.prototype.dispatchActions = function () {
|
||||||
return alive;
|
return alive;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.markRunnable = function (pid) {
|
Dataspace.prototype.markRunnable = function (pid) {
|
||||||
this.runnablePids = this.runnablePids.add(pid);
|
this.runnablePids = this.runnablePids.add(pid);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.runRunnablePids = function () {
|
Dataspace.prototype.runRunnablePids = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var pidSet = this.runnablePids;
|
var pidSet = this.runnablePids;
|
||||||
this.runnablePids = Immutable.Set();
|
this.runnablePids = Immutable.Set();
|
||||||
|
@ -219,7 +219,7 @@ Network.prototype.runRunnablePids = function () {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.interpretAction = function (pid, action) {
|
Dataspace.prototype.interpretAction = function (pid, action) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
@ -233,7 +233,7 @@ Network.prototype.interpretAction = function (pid, action) {
|
||||||
console.warn('Process ' + pid + ' send message containing query', action.message);
|
console.warn('Process ' + pid + ' send message containing query', action.message);
|
||||||
}
|
}
|
||||||
if (pid !== 'meta' && Patch.isAtMeta(action.message)) {
|
if (pid !== 'meta' && Patch.isAtMeta(action.message)) {
|
||||||
Network.send(action.message[1]);
|
Dataspace.send(action.message[1]);
|
||||||
} else {
|
} else {
|
||||||
this.mux.routeMessage(action.message).forEach(function (pid) {
|
this.mux.routeMessage(action.message).forEach(function (pid) {
|
||||||
self.deliverEvent(pid, action);
|
self.deliverEvent(pid, action);
|
||||||
|
@ -262,8 +262,8 @@ Network.prototype.interpretAction = function (pid, action) {
|
||||||
this.processTable = this.processTable.remove(pid);
|
this.processTable = this.processTable.remove(pid);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 'terminateNetwork':
|
case 'terminateDataspace':
|
||||||
Network.exit();
|
Dataspace.exit();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -273,17 +273,17 @@ Network.prototype.interpretAction = function (pid, action) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.deliverPatches = function (oldMux, updateStreamResult) {
|
Dataspace.prototype.deliverPatches = function (oldMux, updateStreamResult) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var events = Mux.computeEvents(oldMux, this.mux, updateStreamResult);
|
var events = Mux.computeEvents(oldMux, this.mux, updateStreamResult);
|
||||||
events.eventMap.forEach(function (patch, pid) {
|
events.eventMap.forEach(function (patch, pid) {
|
||||||
self.deliverEvent(pid, stateChange(patch));
|
self.deliverEvent(pid, stateChange(patch));
|
||||||
});
|
});
|
||||||
events.metaEvents.forEach(Network.stateChange);
|
events.metaEvents.forEach(Dataspace.stateChange);
|
||||||
this.onStateChange(this.mux, updateStreamResult.deltaAggregate);
|
this.onStateChange(this.mux, updateStreamResult.deltaAggregate);
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.deliverEvent = function (pid, event) {
|
Dataspace.prototype.deliverEvent = function (pid, event) {
|
||||||
var childBusy = this.asChild(pid, function (p) { return p.behavior.handleEvent(event); });
|
var childBusy = this.asChild(pid, function (p) { return p.behavior.handleEvent(event); });
|
||||||
if (childBusy) this.markRunnable(pid);
|
if (childBusy) this.markRunnable(pid);
|
||||||
};
|
};
|
||||||
|
@ -294,6 +294,6 @@ module.exports.stateChange = stateChange;
|
||||||
module.exports.message = message;
|
module.exports.message = message;
|
||||||
module.exports.spawn = spawn;
|
module.exports.spawn = spawn;
|
||||||
module.exports.terminate = terminate;
|
module.exports.terminate = terminate;
|
||||||
module.exports.terminateNetwork = terminateNetwork;
|
module.exports.terminateDataspace = terminateDataspace;
|
||||||
|
|
||||||
module.exports.Network = Network;
|
module.exports.Dataspace = Dataspace;
|
|
@ -4,20 +4,20 @@ var DemandMatcher = require('./demand-matcher.js').DemandMatcher;
|
||||||
var Ack = require('./ack.js').Ack;
|
var Ack = require('./ack.js').Ack;
|
||||||
var Seal = require('./seal.js').Seal;
|
var Seal = require('./seal.js').Seal;
|
||||||
|
|
||||||
var Network_ = require("./network.js");
|
var Dataspace_ = require("./dataspace.js");
|
||||||
var Network = Network_.Network;
|
var Dataspace = Dataspace_.Dataspace;
|
||||||
var __ = Network_.__;
|
var __ = Dataspace_.__;
|
||||||
var _$ = Network_._$;
|
var _$ = Dataspace_._$;
|
||||||
|
|
||||||
function spawnDOMDriver(domWrapFunction, jQueryWrapFunction) {
|
function spawnDOMDriver(domWrapFunction, jQueryWrapFunction) {
|
||||||
domWrapFunction = domWrapFunction || defaultWrapFunction;
|
domWrapFunction = domWrapFunction || defaultWrapFunction;
|
||||||
var spec = domWrapFunction(_$('selector'), _$('fragmentClass'), _$('fragmentSpec'));
|
var spec = domWrapFunction(_$('selector'), _$('fragmentClass'), _$('fragmentSpec'));
|
||||||
Network.spawn(
|
Dataspace.spawn(
|
||||||
new DemandMatcher(spec,
|
new DemandMatcher(spec,
|
||||||
Patch.advertise(spec),
|
Patch.advertise(spec),
|
||||||
{
|
{
|
||||||
onDemandIncrease: function (c) {
|
onDemandIncrease: function (c) {
|
||||||
Network.spawn(new DOMFragment(c.selector,
|
Dataspace.spawn(new DOMFragment(c.selector,
|
||||||
c.fragmentClass,
|
c.fragmentClass,
|
||||||
c.fragmentSpec,
|
c.fragmentSpec,
|
||||||
domWrapFunction,
|
domWrapFunction,
|
||||||
|
@ -45,11 +45,11 @@ DOMFragment.prototype.boot = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var specification = self.domWrapFunction(self.selector, self.fragmentClass, self.fragmentSpec);
|
var specification = self.domWrapFunction(self.selector, self.fragmentClass, self.fragmentSpec);
|
||||||
|
|
||||||
Network.spawn(new Network(function () {
|
Dataspace.spawn(new Dataspace(function () {
|
||||||
Syndicate.JQuery.spawnJQueryDriver(self.selector+" > ."+self.fragmentClass,
|
Syndicate.JQuery.spawnJQueryDriver(self.selector+" > ."+self.fragmentClass,
|
||||||
1,
|
1,
|
||||||
self.jQueryWrapFunction);
|
self.jQueryWrapFunction);
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
demandExists: false,
|
demandExists: false,
|
||||||
subscriptionEstablished: new Ack(1),
|
subscriptionEstablished: new Ack(1),
|
||||||
boot: function () {
|
boot: function () {
|
||||||
|
@ -63,7 +63,7 @@ DOMFragment.prototype.boot = function () {
|
||||||
if (e.patch.hasRemoved()) this.demandExists = false;
|
if (e.patch.hasRemoved()) this.demandExists = false;
|
||||||
}
|
}
|
||||||
if (this.subscriptionEstablished.done && !this.demandExists) {
|
if (this.subscriptionEstablished.done && !this.demandExists) {
|
||||||
Network.exitNetwork();
|
Dataspace.exitDataspace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -84,7 +84,7 @@ DOMFragment.prototype.handleEvent = function (e) {
|
||||||
var n = this.nodes[i];
|
var n = this.nodes[i];
|
||||||
n.parentNode.removeChild(n);
|
n.parentNode.removeChild(n);
|
||||||
}
|
}
|
||||||
Network.exit();
|
Dataspace.exit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Immutable = require('immutable');
|
var Immutable = require('immutable');
|
||||||
var Network = require('./network.js').Network;
|
var Dataspace = require('./dataspace.js').Dataspace;
|
||||||
|
|
||||||
function Ground(bootFn) {
|
function Ground(bootFn) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.stepperId = null;
|
this.stepperId = null;
|
||||||
this.baseStack = Immutable.List.of({ network: this, activePid: -1 });
|
this.baseStack = Immutable.List.of({ dataspace: this, activePid: -1 });
|
||||||
Network.withNetworkStack(this.baseStack, function () {
|
Dataspace.withDataspaceStack(this.baseStack, function () {
|
||||||
self.network = new Network(bootFn);
|
self.dataspace = new Dataspace(bootFn);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ground.prototype.step = function () {
|
Ground.prototype.step = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
return Network.withNetworkStack(this.baseStack, function () {
|
return Dataspace.withDataspaceStack(this.baseStack, function () {
|
||||||
return self.network.step();
|
return self.dataspace.step();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ Ground.prototype.stopStepping = function () {
|
||||||
|
|
||||||
Ground.prototype.kill = function (pid, exn) {
|
Ground.prototype.kill = function (pid, exn) {
|
||||||
this.checkPid(pid);
|
this.checkPid(pid);
|
||||||
console.log("Ground network terminated");
|
console.log("Ground dataspace terminated");
|
||||||
this.stopStepping();
|
this.stopStepping();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
var Patch = require("./patch.js");
|
var Patch = require("./patch.js");
|
||||||
var DemandMatcher = require('./demand-matcher.js').DemandMatcher;
|
var DemandMatcher = require('./demand-matcher.js').DemandMatcher;
|
||||||
|
|
||||||
var Network_ = require("./network.js");
|
var Dataspace_ = require("./dataspace.js");
|
||||||
var Network = Network_.Network;
|
var Dataspace = Dataspace_.Dataspace;
|
||||||
var __ = Network_.__;
|
var __ = Dataspace_.__;
|
||||||
var _$ = Network_._$;
|
var _$ = Dataspace_._$;
|
||||||
|
|
||||||
function spawnJQueryDriver(baseSelector, metaLevel, wrapFunction) {
|
function spawnJQueryDriver(baseSelector, metaLevel, wrapFunction) {
|
||||||
metaLevel = metaLevel || 0;
|
metaLevel = metaLevel || 0;
|
||||||
wrapFunction = wrapFunction || defaultWrapFunction;
|
wrapFunction = wrapFunction || defaultWrapFunction;
|
||||||
Network.spawn(
|
Dataspace.spawn(
|
||||||
new DemandMatcher(Patch.observe(wrapFunction(_$('selector'), _$('eventName'), __)),
|
new DemandMatcher(Patch.observe(wrapFunction(_$('selector'), _$('eventName'), __)),
|
||||||
Patch.advertise(wrapFunction(_$('selector'), _$('eventName'), __)),
|
Patch.advertise(wrapFunction(_$('selector'), _$('eventName'), __)),
|
||||||
{
|
{
|
||||||
metaLevel: metaLevel,
|
metaLevel: metaLevel,
|
||||||
onDemandIncrease: function (c) {
|
onDemandIncrease: function (c) {
|
||||||
Network.spawn(new JQueryEventRouter(baseSelector,
|
Dataspace.spawn(new JQueryEventRouter(baseSelector,
|
||||||
c.selector,
|
c.selector,
|
||||||
c.eventName,
|
c.eventName,
|
||||||
metaLevel,
|
metaLevel,
|
||||||
|
@ -38,8 +38,8 @@ function JQueryEventRouter(baseSelector, selector, eventName, metaLevel, wrapFun
|
||||||
this.wrapFunction = wrapFunction || defaultWrapFunction;
|
this.wrapFunction = wrapFunction || defaultWrapFunction;
|
||||||
this.preventDefault = (this.eventName.charAt(0) !== "+");
|
this.preventDefault = (this.eventName.charAt(0) !== "+");
|
||||||
this.handler =
|
this.handler =
|
||||||
Network.wrap(function (e) {
|
Dataspace.wrap(function (e) {
|
||||||
Network.send(self.wrapFunction(self.selector, self.eventName, e), self.metaLevel);
|
Dataspace.send(self.wrapFunction(self.selector, self.eventName, e), self.metaLevel);
|
||||||
if (self.preventDefault) e.preventDefault();
|
if (self.preventDefault) e.preventDefault();
|
||||||
return !self.preventDefault;
|
return !self.preventDefault;
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ JQueryEventRouter.prototype.boot = function () {
|
||||||
JQueryEventRouter.prototype.handleEvent = function (e) {
|
JQueryEventRouter.prototype.handleEvent = function (e) {
|
||||||
if (e.type === "stateChange" && e.patch.hasRemoved()) {
|
if (e.type === "stateChange" && e.patch.hasRemoved()) {
|
||||||
this.computeNodes().off(this.eventName, this.handler);
|
this.computeNodes().off(this.eventName, this.handler);
|
||||||
Network.exit();
|
Dataspace.exit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ function copyKeys(keys, to, from) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = require("./network.js");
|
module.exports = require("./dataspace.js");
|
||||||
|
|
||||||
module.exports.Route = require("./route.js");
|
module.exports.Route = require("./route.js");
|
||||||
copyKeys(['__', '_$', '$Capture', '$Special',
|
copyKeys(['__', '_$', '$Capture', '$Special',
|
||||||
|
|
|
@ -4,7 +4,7 @@ var expect = require('expect.js');
|
||||||
var Immutable = require('immutable');
|
var Immutable = require('immutable');
|
||||||
|
|
||||||
var Syndicate = require('../src/main.js');
|
var Syndicate = require('../src/main.js');
|
||||||
var Network = Syndicate.Network;
|
var Dataspace = Syndicate.Dataspace;
|
||||||
var Patch = Syndicate.Patch;
|
var Patch = Syndicate.Patch;
|
||||||
|
|
||||||
var __ = Syndicate.__;
|
var __ = Syndicate.__;
|
||||||
|
@ -53,12 +53,12 @@ describe("configurationTrace", function() {
|
||||||
describe("with some traced communication", function () {
|
describe("with some traced communication", function () {
|
||||||
it("should yield an appropriate trace", function () {
|
it("should yield an appropriate trace", function () {
|
||||||
checkTrace(function (trace) {
|
checkTrace(function (trace) {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () { return Syndicate.sub(__); },
|
boot: function () { return Syndicate.sub(__); },
|
||||||
handleEvent: traceEvent(trace)
|
handleEvent: traceEvent(trace)
|
||||||
});
|
});
|
||||||
Network.send(123);
|
Dataspace.send(123);
|
||||||
Network.send(234);
|
Dataspace.send(234);
|
||||||
}, ['<<<<<<<< Removed:\n'+
|
}, ['<<<<<<<< Removed:\n'+
|
||||||
'::: nothing\n'+
|
'::: nothing\n'+
|
||||||
'======== Added:\n'+
|
'======== Added:\n'+
|
||||||
|
@ -75,11 +75,11 @@ describe("nonempty initial routes", function () {
|
||||||
it("should be immediately signalled to the process", function () {
|
it("should be immediately signalled to the process", function () {
|
||||||
// Specifically, no Syndicate.updateRoutes([]) first.
|
// Specifically, no Syndicate.updateRoutes([]) first.
|
||||||
checkTrace(function (trace) {
|
checkTrace(function (trace) {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () { return Patch.assert(["A", __]); },
|
boot: function () { return Patch.assert(["A", __]); },
|
||||||
handleEvent: function (e) {}
|
handleEvent: function (e) {}
|
||||||
});
|
});
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () { return Patch.sub(["A", __]); },
|
boot: function () { return Patch.sub(["A", __]); },
|
||||||
handleEvent: traceEvent(trace)
|
handleEvent: traceEvent(trace)
|
||||||
});
|
});
|
||||||
|
@ -94,10 +94,10 @@ describe("nonempty initial routes", function () {
|
||||||
describe("nested actor with an echoey protocol", function () {
|
describe("nested actor with an echoey protocol", function () {
|
||||||
it("shouldn't see an echoed assertion", function () {
|
it("shouldn't see an echoed assertion", function () {
|
||||||
checkTrace(function (trace) {
|
checkTrace(function (trace) {
|
||||||
Network.spawn(new Network(function () {
|
Dataspace.spawn(new Dataspace(function () {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () {
|
boot: function () {
|
||||||
Network.stateChange(Patch.retract("X", 1)); // happens after subs on next line!
|
Dataspace.stateChange(Patch.retract("X", 1)); // happens after subs on next line!
|
||||||
return Patch.sub("X", 1).andThen(Patch.assert("X", 1));
|
return Patch.sub("X", 1).andThen(Patch.assert("X", 1));
|
||||||
},
|
},
|
||||||
handleEvent: traceEvent(trace)
|
handleEvent: traceEvent(trace)
|
||||||
|
@ -116,10 +116,10 @@ describe("nested actor with an echoey protocol", function () {
|
||||||
})
|
})
|
||||||
it("shouldn't see an echoed message", function () {
|
it("shouldn't see an echoed message", function () {
|
||||||
checkTrace(function (trace) {
|
checkTrace(function (trace) {
|
||||||
Network.spawn(new Network(function () {
|
Dataspace.spawn(new Dataspace(function () {
|
||||||
Network.spawn({
|
Dataspace.spawn({
|
||||||
boot: function () {
|
boot: function () {
|
||||||
Network.send("X", 1); // happens after subs on next line!
|
Dataspace.send("X", 1); // happens after subs on next line!
|
||||||
return Patch.sub("X", 1);
|
return Patch.sub("X", 1);
|
||||||
},
|
},
|
||||||
handleEvent: traceEvent(trace)
|
handleEvent: traceEvent(trace)
|
||||||
|
@ -134,10 +134,10 @@ describe("nested actor with an echoey protocol", function () {
|
||||||
// describe("actor with nonempty initial routes", function () {
|
// describe("actor with nonempty initial routes", function () {
|
||||||
// it("shouldn't see initial empty conversational context", function () {
|
// it("shouldn't see initial empty conversational context", function () {
|
||||||
// checkTrace(function (trace) {
|
// checkTrace(function (trace) {
|
||||||
// Network.spawn({
|
// Dataspace.spawn({
|
||||||
// boot: function () { return [pub(["A", __])] },
|
// boot: function () { return [pub(["A", __])] },
|
||||||
// handleEvent: function (e) {
|
// handleEvent: function (e) {
|
||||||
// Network.spawn(new Actor(function () {
|
// Dataspace.spawn(new Actor(function () {
|
||||||
// Actor.observeAdvertisers(
|
// Actor.observeAdvertisers(
|
||||||
// function () { return ["A", __] },
|
// function () { return ["A", __] },
|
||||||
// { presence: "isPresent" },
|
// { presence: "isPresent" },
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* How do I run a syndicate program?
|
* How do I run a syndicate program?
|
||||||
- `#lang syndicate` collects actions (`spawn`s) from module toplevel and
|
- `#lang syndicate` collects actions (`spawn`s) from module toplevel and
|
||||||
uses them as boot actions for a ground-level network. The alternative
|
uses them as boot actions for a ground-level dataspace. The alternative
|
||||||
is to use a different #lang, and to call `run-ground` yourself; see an
|
is to use a different #lang, and to call `run-ground` yourself; see an
|
||||||
example in syndicate/examples/example-plain.rkt.
|
example in syndicate/examples/example-plain.rkt.
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
p - lifecycle events (spawns, crashes, and quits)
|
p - lifecycle events (spawns, crashes, and quits)
|
||||||
a - process actions
|
a - process actions
|
||||||
g - dataspace contents
|
g - dataspace contents
|
||||||
Adding 'N' will show whole network-states too. Remove each individual
|
Adding 'N' will show whole dataspace-states too. Remove each individual
|
||||||
character to turn off the corresponding trace facility; the default
|
character to turn off the corresponding trace facility; the default
|
||||||
value of the variable is just the empty-string.
|
value of the variable is just the empty-string.
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@
|
||||||
;; stateless actor
|
;; stateless actor
|
||||||
(spawn/stateless (lambda (event) ... (list action ...))
|
(spawn/stateless (lambda (event) ... (list action ...))
|
||||||
initial-action ...)
|
initial-action ...)
|
||||||
;; network of actors
|
;; dataspace of actors
|
||||||
(spawn-network boot-action ...)
|
(spawn-dataspace boot-action ...)
|
||||||
```
|
```
|
||||||
|
|
||||||
* How do actors at different levels communicate?
|
* How do actors at different levels communicate?
|
||||||
|
@ -98,9 +98,9 @@
|
||||||
while the second says
|
while the second says
|
||||||
> OVER THERE, I am interested in assertions 'hello
|
> OVER THERE, I am interested in assertions 'hello
|
||||||
|
|
||||||
The former is necessary for the local network to route events to us, and
|
The former is necessary for the local dataspace to route events to us, and
|
||||||
the latter is necessary for the remote network to route events to the
|
the latter is necessary for the remote dataspace to route events to the
|
||||||
local network.
|
local dataspace.
|
||||||
|
|
||||||
Implicit in any `sub` call with N>0 meta-level, therefore, is the
|
Implicit in any `sub` call with N>0 meta-level, therefore, is the
|
||||||
construction of a whole *chain* of subscriptions, relaying information
|
construction of a whole *chain* of subscriptions, relaying information
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
When a message is sent, it is delivered to everyone that is interested in it
|
When a message is sent, it is delivered to everyone that is interested in it
|
||||||
**at that time**.
|
**at that time**.
|
||||||
|
|
||||||
* How to inject an external event (e.g. keyboard press) into the network?
|
* How to inject an external event (e.g. keyboard press) into the dataspace?
|
||||||
- Use `send-ground-message`.
|
- Use `send-ground-message`.
|
||||||
- (Note that the argument to `send-ground-message` is wrapped in a `message`,
|
- (Note that the argument to `send-ground-message` is wrapped in a `message`,
|
||||||
so to send `'foo` at the ground level use `(send-ground-message 'foo)` rather than
|
so to send `'foo` at the ground level use `(send-ground-message 'foo)` rather than
|
||||||
|
@ -191,10 +191,10 @@
|
||||||
|
|
||||||
* I used `spawn` but the actor isn't being created. What happened?
|
* I used `spawn` but the actor isn't being created. What happened?
|
||||||
- The only two ways to spawn a process are to (a) supply the spawn instruction in
|
- The only two ways to spawn a process are to (a) supply the spawn instruction in
|
||||||
that network's boot-actions, or (b) have some already-existing actor supply the
|
that dataspace's boot-actions, or (b) have some already-existing actor supply the
|
||||||
spawn instruction in response to some event it receives. Note that calling `spawn`
|
spawn instruction in response to some event it receives. Note that calling `spawn`
|
||||||
constructs a structure which is perhaps eventually interpreted by the containing
|
constructs a structure which is perhaps eventually interpreted by the containing
|
||||||
network of an actor; it doesn't really "do" anything directly.
|
dataspace of an actor; it doesn't really "do" anything directly.
|
||||||
|
|
||||||
* Why does `patch-seq` exist? Aren't all the actions in a transition effectively `patch-seq`d together?
|
* Why does `patch-seq` exist? Aren't all the actions in a transition effectively `patch-seq`d together?
|
||||||
- Effectively, yes, that is what happens. The difference is in the
|
- Effectively, yes, that is what happens. The difference is in the
|
||||||
|
@ -210,7 +210,7 @@
|
||||||
gets to observe things-as-they-were-before-the-patch, and
|
gets to observe things-as-they-were-before-the-patch, and
|
||||||
things-as-they-are-after-the-patch.
|
things-as-they-are-after-the-patch.
|
||||||
|
|
||||||
* How do I create a tiered network, such as
|
* How do I create a tiered dataspace, such as
|
||||||
```
|
```
|
||||||
ground
|
ground
|
||||||
/ \
|
/ \
|
||||||
|
@ -218,15 +218,15 @@
|
||||||
\
|
\
|
||||||
net3
|
net3
|
||||||
```
|
```
|
||||||
- use `spawn-network`:
|
- use `spawn-dataspace`:
|
||||||
```racket
|
```racket
|
||||||
#lang syndicate
|
#lang syndicate
|
||||||
(spawn-network <net1-spawns> ...)
|
(spawn-dataspace <net1-spawns> ...)
|
||||||
(spawn-network <net2-spawns> ...
|
(spawn-dataspace <net2-spawns> ...
|
||||||
(spawn-network <net3-spawns> ...))
|
(spawn-dataspace <net3-spawns> ...))
|
||||||
```
|
```
|
||||||
`spawn-network` expands into a regular `spawn` with an event-handler and
|
`spawn-dataspace` expands into a regular `spawn` with an event-handler and
|
||||||
state corresponding to a whole VM. The arguments to spawn-network are
|
state corresponding to a whole VM. The arguments to spawn-dataspace are
|
||||||
actions to take at boot time in the new VM.
|
actions to take at boot time in the new VM.
|
||||||
|
|
||||||
* What is the outcome if I do `(assert X)` and then later `(patch-seq (retract ?) assert X)`?
|
* What is the outcome if I do `(assert X)` and then later `(patch-seq (retract ?) assert X)`?
|
||||||
|
@ -275,4 +275,4 @@
|
||||||
* Why does `#f` keep getting sent as an event?
|
* Why does `#f` keep getting sent as an event?
|
||||||
- When a behavior returns something besides `#f` in response to an event, it is
|
- When a behavior returns something besides `#f` in response to an event, it is
|
||||||
repeatedly sent `#f` until it does return `#f`.
|
repeatedly sent `#f` until it does return `#f`.
|
||||||
- Think of it as a way of the network asking "anything else?"
|
- Think of it as a way of the dataspace asking "anything else?"
|
||||||
|
|
|
@ -37,15 +37,15 @@
|
||||||
(idle 0 (- mx dx) (- my dy))]))
|
(idle 0 (- mx dx) (- my dy))]))
|
||||||
(actor (idle 0 orig-x orig-y)))
|
(actor (idle 0 orig-x orig-y)))
|
||||||
|
|
||||||
(big-bang-network #:width 640
|
(big-bang-dataspace #:width 640
|
||||||
#:height 480
|
#:height 480
|
||||||
(actor (forever
|
(actor (forever
|
||||||
(on (asserted (active-window $id) #:meta-level 1)
|
(on (asserted (active-window $id) #:meta-level 1)
|
||||||
(update-window 'active-window-label 300 0
|
(update-window 'active-window-label 300 0
|
||||||
(text (format "~v" id) 22 "black")))))
|
(text (format "~v" id) 22 "black")))))
|
||||||
(button #:background "red" 'stop-button 0 0 "Exit"
|
(button #:background "red" 'stop-button 0 0 "Exit"
|
||||||
(lambda () (assert! 'stop #:meta-level 1)))
|
(lambda () (assert! 'stop #:meta-level 1)))
|
||||||
(draggable-shape 'c1 50 50 (circle 30 "solid" "orange"))
|
(draggable-shape 'c1 50 50 (circle 30 "solid" "orange"))
|
||||||
(draggable-shape 's1 100 100 (star 40 "solid" "firebrick")))
|
(draggable-shape 's1 100 100 (star 40 "solid" "firebrick")))
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
(on `(,$who says ,$what) (say who "says: ~a" what))
|
(on `(,$who says ,$what) (say who "says: ~a" what))
|
||||||
(on (message (at-meta (tcp-channel them us $bs)))
|
(on (message (at-meta (tcp-channel them us $bs)))
|
||||||
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
||||||
(if (equal? input-string "quit-network")
|
(if (equal? input-string "quit-dataspace")
|
||||||
(assert! 'quit-network)
|
(assert! 'quit-dataspace)
|
||||||
(send! `(,user says ,input-string)))))
|
(send! `(,user says ,input-string)))))
|
||||||
(send-to-remote "Goodbye!\n")))
|
(send-to-remote "Goodbye!\n")))
|
||||||
|
|
||||||
(spawn-tcp-driver)
|
(spawn-tcp-driver)
|
||||||
(let ((us (tcp-listener 5999)))
|
(let ((us (tcp-listener 5999)))
|
||||||
(group (until (asserted 'quit-network)
|
(group (until (asserted 'quit-dataspace)
|
||||||
(on (asserted (advertise (tcp-channel $them us ?)) #:meta-level 1)
|
(on (asserted (advertise (tcp-channel $them us ?)) #:meta-level 1)
|
||||||
(spawn-session them us)))))
|
(spawn-session them us)))))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Just a sketch, at the moment.
|
Just a sketch, at the moment.
|
||||||
|
|
||||||
Instantaneous actions, I := (actor I ...)
|
Instantaneous actions, I := (actor I ...)
|
||||||
(network I ...)
|
(dataspace I ...)
|
||||||
(state [B O ...] [E I ...] ...)
|
(state [B O ...] [E I ...] ...)
|
||||||
(background I ...)
|
(background I ...)
|
||||||
(assert! P)
|
(assert! P)
|
||||||
|
@ -52,8 +52,8 @@ value(s) of the final `I` from the `E` exit branch that was chosen
|
||||||
*prepended* to the values of the calling actor's variables at the time
|
*prepended* to the values of the calling actor's variables at the time
|
||||||
of `state` termination.
|
of `state` termination.
|
||||||
|
|
||||||
There are four kinds of actor-spawning `I`s: `actor`, `network`,
|
There are four kinds of actor-spawning `I`s: `actor`, `dataspace`,
|
||||||
`state` and `background`. Neither `actor`, `network` nor `background`
|
`state` and `background`. Neither `actor`, `dataspace` nor `background`
|
||||||
yield a value; only `state` does so. However, both `state` and
|
yield a value; only `state` does so. However, both `state` and
|
||||||
`background` link to their invoking contexts, because `state` may
|
`background` link to their invoking contexts, because `state` may
|
||||||
return values or crash, and `background` may crash. Actors using
|
return values or crash, and `background` may crash. Actors using
|
||||||
|
@ -66,7 +66,7 @@ Q: Should exception values be transmitted on `state` failure? I think
|
||||||
no, but I am not sure there's a good reason why not.
|
no, but I am not sure there's a good reason why not.
|
||||||
|
|
||||||
Of the events, `asserted`, `retracted` and `message` require no
|
Of the events, `asserted`, `retracted` and `message` require no
|
||||||
private-state, since the network does the book-keeping for us.
|
private-state, since the dataspace does the book-keeping for us.
|
||||||
`rising-edge`, however, needs to track the state of its predicate. If
|
`rising-edge`, however, needs to track the state of its predicate. If
|
||||||
the predicate happens to involve an `exists`, then an assertion set
|
the predicate happens to involve an `exists`, then an assertion set
|
||||||
must be maintained, like for a `track`.
|
must be maintained, like for a `track`.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
update-scene
|
update-scene
|
||||||
update-sprites
|
update-sprites
|
||||||
spawn-keyboard-integrator
|
spawn-keyboard-integrator
|
||||||
2d-network)
|
2d-dataspace)
|
||||||
|
|
||||||
(require data/order)
|
(require data/order)
|
||||||
(require data/splay-tree)
|
(require data/splay-tree)
|
||||||
|
@ -31,13 +31,13 @@
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; Shared state maintained by network. Describes current window dimensions.
|
;; Shared state maintained by dataspace. Describes current window dimensions.
|
||||||
(struct window (width height) #:transparent)
|
(struct window (width height) #:transparent)
|
||||||
|
|
||||||
;; Message sent by network. Describes frame about to be rendered.
|
;; Message sent by dataspace. Describes frame about to be rendered.
|
||||||
(struct frame-event (counter timestamp elapsed-ms target-frame-rate) #:transparent)
|
(struct frame-event (counter timestamp elapsed-ms target-frame-rate) #:transparent)
|
||||||
|
|
||||||
;; Message sent by network. Describes a key event. Key is a sealed
|
;; Message sent by dataspace. Describes a key event. Key is a sealed
|
||||||
;; key-event%. `press?` is #t when the key is pressed (or
|
;; key-event%. `press?` is #t when the key is pressed (or
|
||||||
;; autorepeated!), and #f when it is released.
|
;; autorepeated!), and #f when it is released.
|
||||||
(struct key-event (code press? key) #:transparent)
|
(struct key-event (code press? key) #:transparent)
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define network-canvas%
|
(define dataspace-canvas%
|
||||||
(class canvas%
|
(class canvas%
|
||||||
(inherit refresh with-gl-context swap-gl-buffers)
|
(inherit refresh with-gl-context swap-gl-buffers)
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@
|
||||||
(define postlude empty-instructions)
|
(define postlude empty-instructions)
|
||||||
(define fullscreen? #f)
|
(define fullscreen? #f)
|
||||||
|
|
||||||
(define network (make-network boot-actions))
|
(define dataspace (make-dataspace boot-actions))
|
||||||
(define event-queue (make-queue))
|
(define event-queue (make-queue))
|
||||||
|
|
||||||
(define target-frame-rate 60)
|
(define target-frame-rate 60)
|
||||||
|
@ -266,7 +266,7 @@
|
||||||
(enqueue! event-queue e))
|
(enqueue! event-queue e))
|
||||||
|
|
||||||
(define (deliver-event e)
|
(define (deliver-event e)
|
||||||
(clean-transition (network-handle-event e network)))
|
(clean-transition (dataspace-handle-event e dataspace)))
|
||||||
|
|
||||||
(define (quiesce!)
|
(define (quiesce!)
|
||||||
(let loop ((txn #f) (need-poll? #t))
|
(let loop ((txn #f) (need-poll? #t))
|
||||||
|
@ -275,8 +275,8 @@
|
||||||
(if (queue-empty? event-queue)
|
(if (queue-empty? event-queue)
|
||||||
(when need-poll? (loop (deliver-event #f) #f))
|
(when need-poll? (loop (deliver-event #f) #f))
|
||||||
(loop (deliver-event (dequeue! event-queue)) #t))]
|
(loop (deliver-event (dequeue! event-queue)) #t))]
|
||||||
[(transition new-network actions)
|
[(transition new-dataspace actions)
|
||||||
(set! network new-network)
|
(set! dataspace new-dataspace)
|
||||||
(for-each process-action! actions)
|
(for-each process-action! actions)
|
||||||
(loop #f #t)])))
|
(loop #f #t)])))
|
||||||
|
|
||||||
|
@ -387,9 +387,9 @@
|
||||||
|
|
||||||
(super-new (style '(gl no-autoclear)))))
|
(super-new (style '(gl no-autoclear)))))
|
||||||
|
|
||||||
(define (2d-network #:width [width #f]
|
(define (2d-dataspace #:width [width #f]
|
||||||
#:height [height #f]
|
#:height [height #f]
|
||||||
. boot-actions)
|
. boot-actions)
|
||||||
(collect-garbage 'incremental)
|
(collect-garbage 'incremental)
|
||||||
(collect-garbage 'major)
|
(collect-garbage 'major)
|
||||||
(define frame (new frame%
|
(define frame (new frame%
|
||||||
|
@ -397,11 +397,11 @@
|
||||||
[label "syndicate-gl"]
|
[label "syndicate-gl"]
|
||||||
[width (or width 640)]
|
[width (or width 640)]
|
||||||
[height (or height 480)]))
|
[height (or height 480)]))
|
||||||
(define c (new network-canvas%
|
(define c (new dataspace-canvas%
|
||||||
[parent frame]
|
[parent frame]
|
||||||
[boot-actions boot-actions]))
|
[boot-actions boot-actions]))
|
||||||
(unless (send (send (send c get-dc) get-gl-context) ok?)
|
(unless (send (send (send c get-dc) get-gl-context) ok?)
|
||||||
(error '2d-network "OpenGL context failed to initialize"))
|
(error '2d-dataspace "OpenGL context failed to initialize"))
|
||||||
(send c focus)
|
(send c focus)
|
||||||
(send frame show #t)
|
(send frame show #t)
|
||||||
(yield 'wait))
|
(yield 'wait))
|
||||||
|
|
|
@ -77,20 +77,20 @@
|
||||||
(void)
|
(void)
|
||||||
(sub (frame-event ? ? ? ?) #:meta-level 1)))
|
(sub (frame-event ? ? ? ?) #:meta-level 1)))
|
||||||
|
|
||||||
(2d-network (spawn-keyboard-integrator)
|
(2d-dataspace (spawn-keyboard-integrator)
|
||||||
(spawn-background)
|
(spawn-background)
|
||||||
;; (spawn-frame-counter)
|
;; (spawn-frame-counter)
|
||||||
(spawn-player-avatar)
|
(spawn-player-avatar)
|
||||||
(spawn (lambda (e s) #f)
|
(spawn (lambda (e s) #f)
|
||||||
(void)
|
(void)
|
||||||
(update-sprites (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange"))
|
(update-sprites (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange"))
|
||||||
(simple-sprite -1 60 60 50 50 (circle 50 "solid" "green"))))
|
(simple-sprite -1 60 60 50 50 (circle 50 "solid" "green"))))
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
[(message _)
|
[(message _)
|
||||||
(transition s (assert 'stop #:meta-level 1))]
|
(transition s (assert 'stop #:meta-level 1))]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
(void)
|
(void)
|
||||||
(sub (key-event #\q #t ?) #:meta-level 1))
|
(sub (key-event #\q #t ?) #:meta-level 1))
|
||||||
)
|
)
|
||||||
(exit 0)
|
(exit 0)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
;; Core implementation of Incremental Network Calculus.
|
;; Core implementation of Monolithic Syndicate.
|
||||||
|
|
||||||
(provide (struct-out message)
|
(provide (struct-out message)
|
||||||
(except-out (struct-out quit) quit)
|
(except-out (struct-out quit) quit)
|
||||||
(struct-out quit-network)
|
(struct-out quit-dataspace)
|
||||||
(rename-out [quit <quit>])
|
(rename-out [quit <quit>])
|
||||||
(except-out (struct-out spawn) spawn)
|
(except-out (struct-out spawn) spawn)
|
||||||
(rename-out [spawn <spawn>])
|
(rename-out [spawn <spawn>])
|
||||||
(struct-out transition)
|
(struct-out transition)
|
||||||
(struct-out network)
|
(struct-out dataspace)
|
||||||
|
|
||||||
(struct-out seal)
|
(struct-out seal)
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@
|
||||||
scn/union
|
scn/union
|
||||||
|
|
||||||
(rename-out [make-quit quit])
|
(rename-out [make-quit quit])
|
||||||
make-network
|
make-dataspace
|
||||||
spawn-network
|
spawn-dataspace
|
||||||
(rename-out [spawn-process spawn])
|
(rename-out [spawn-process spawn])
|
||||||
spawn/stateless
|
spawn/stateless
|
||||||
make-spawn-network
|
make-spawn-dataspace
|
||||||
|
|
||||||
transition-bind
|
transition-bind
|
||||||
sequence-transitions
|
sequence-transitions
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
sequence-transitions0
|
sequence-transitions0
|
||||||
sequence-transitions0*
|
sequence-transitions0*
|
||||||
|
|
||||||
network-handle-event
|
dataspace-handle-event
|
||||||
clean-transition
|
clean-transition
|
||||||
|
|
||||||
pretty-print-network)
|
pretty-print-dataspace)
|
||||||
|
|
||||||
(require racket/set)
|
(require racket/set)
|
||||||
(require racket/match)
|
(require racket/match)
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
;; Actions ⊃ Events
|
;; Actions ⊃ Events
|
||||||
(struct spawn (boot) #:prefab)
|
(struct spawn (boot) #:prefab)
|
||||||
(struct quit-network () #:prefab) ;; NB. An action. Compare (quit), a Transition.
|
(struct quit-dataspace () #:prefab) ;; NB. An action. Compare (quit), a Transition.
|
||||||
|
|
||||||
;; A Behavior is a ((Option Event) Any -> Transition): a function
|
;; A Behavior is a ((Option Event) Any -> Transition): a function
|
||||||
;; mapping an Event (or, in the #f case, a poll signal) and a
|
;; mapping an Event (or, in the #f case, a poll signal) and a
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
;; - #f, a signal from a Process that it is inert and need not be
|
;; - #f, a signal from a Process that it is inert and need not be
|
||||||
;; scheduled until some Event relevant to it arrives; or,
|
;; scheduled until some Event relevant to it arrives; or,
|
||||||
;; - a (transition Any (Constreeof Action)), a new Process state to
|
;; - a (transition Any (Constreeof Action)), a new Process state to
|
||||||
;; be held by its Network and a sequence of Actions for the Network
|
;; be held by its Dataspace and a sequence of Actions for the Dataspace
|
||||||
;; to take on the transitioning Process's behalf.
|
;; to take on the transitioning Process's behalf.
|
||||||
;; - a (quit (Option Exn) (Constreeof Action)), signalling that the
|
;; - a (quit (Option Exn) (Constreeof Action)), signalling that the
|
||||||
;; Process should never again be handed an event, and that any
|
;; Process should never again be handed an event, and that any
|
||||||
|
@ -104,16 +104,16 @@
|
||||||
;; A Label is a PID or 'meta.
|
;; A Label is a PID or 'meta.
|
||||||
|
|
||||||
;; VM private states
|
;; VM private states
|
||||||
(struct network (mux ;; Multiplexer
|
(struct dataspace (mux ;; Multiplexer
|
||||||
pending-action-queue ;; (Queueof (Cons Label (U Action 'quit)))
|
pending-action-queue ;; (Queueof (Cons Label (U Action 'quit)))
|
||||||
runnable-pids ;; (Setof PID)
|
runnable-pids ;; (Setof PID)
|
||||||
behaviors ;; (HashTable PID Behavior)
|
behaviors ;; (HashTable PID Behavior)
|
||||||
states ;; (HashTable PID Any)
|
states ;; (HashTable PID Any)
|
||||||
)
|
)
|
||||||
#:transparent
|
#:transparent
|
||||||
#:methods gen:syndicate-pretty-printable
|
#:methods gen:syndicate-pretty-printable
|
||||||
[(define (syndicate-pretty-print w [p (current-output-port)])
|
[(define (syndicate-pretty-print w [p (current-output-port)])
|
||||||
(pretty-print-network w p))])
|
(pretty-print-dataspace w p))])
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Seals are used by protocols to prevent the routing tries from
|
;; Seals are used by protocols to prevent the routing tries from
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define (event? x) (or (scn? x) (message? x)))
|
(define (event? x) (or (scn? x) (message? x)))
|
||||||
(define (action? x) (or (event? x) (spawn? x) (quit-network? x)))
|
(define (action? x) (or (event? x) (spawn? x) (quit-dataspace? x)))
|
||||||
|
|
||||||
(define (prepend-at-meta pattern level)
|
(define (prepend-at-meta pattern level)
|
||||||
(if (zero? level)
|
(if (zero? level)
|
||||||
|
@ -181,8 +181,8 @@
|
||||||
(filter action? (flatten actions)))
|
(filter action? (flatten actions)))
|
||||||
|
|
||||||
(define (send-event e pid w)
|
(define (send-event e pid w)
|
||||||
(define behavior (hash-ref (network-behaviors w) pid #f))
|
(define behavior (hash-ref (dataspace-behaviors w) pid #f))
|
||||||
(define old-state (hash-ref (network-states w) pid #f))
|
(define old-state (hash-ref (dataspace-states w) pid #f))
|
||||||
(if (not behavior)
|
(if (not behavior)
|
||||||
w
|
w
|
||||||
(begin
|
(begin
|
||||||
|
@ -205,16 +205,16 @@
|
||||||
(enqueue-actions (disable-process pid exn w) pid (list 'quit)))))))
|
(enqueue-actions (disable-process pid exn w) pid (list 'quit)))))))
|
||||||
|
|
||||||
(define (update-state w pid s)
|
(define (update-state w pid s)
|
||||||
(struct-copy network w [states (hash-set (network-states w) pid s)]))
|
(struct-copy dataspace w [states (hash-set (dataspace-states w) pid s)]))
|
||||||
|
|
||||||
(define (disable-process pid exn w)
|
(define (disable-process pid exn w)
|
||||||
(when exn
|
(when exn
|
||||||
(log-error "Process ~a died with exception:\n~a"
|
(log-error "Process ~a died with exception:\n~a"
|
||||||
(cons pid (trace-pid-stack))
|
(cons pid (trace-pid-stack))
|
||||||
(exn->string exn)))
|
(exn->string exn)))
|
||||||
(struct-copy network w
|
(struct-copy dataspace w
|
||||||
[behaviors (hash-remove (network-behaviors w) pid)]
|
[behaviors (hash-remove (dataspace-behaviors w) pid)]
|
||||||
[states (hash-remove (network-states w) pid)]))
|
[states (hash-remove (dataspace-states w) pid)]))
|
||||||
|
|
||||||
(define (invoke-process pid thunk k-ok k-exn)
|
(define (invoke-process pid thunk k-ok k-exn)
|
||||||
(define-values (ok? result)
|
(define-values (ok? result)
|
||||||
|
@ -228,12 +228,12 @@
|
||||||
(k-exn result)))
|
(k-exn result)))
|
||||||
|
|
||||||
(define (mark-pid-runnable w pid)
|
(define (mark-pid-runnable w pid)
|
||||||
(struct-copy network w [runnable-pids (set-add (network-runnable-pids w) pid)]))
|
(struct-copy dataspace w [runnable-pids (set-add (dataspace-runnable-pids w) pid)]))
|
||||||
|
|
||||||
(define (enqueue-actions w label actions)
|
(define (enqueue-actions w label actions)
|
||||||
(struct-copy network w
|
(struct-copy dataspace w
|
||||||
[pending-action-queue
|
[pending-action-queue
|
||||||
(queue-append-list (network-pending-action-queue w)
|
(queue-append-list (dataspace-pending-action-queue w)
|
||||||
(for/list [(a actions)] (cons label a)))]))
|
(for/list [(a actions)] (cons label a)))]))
|
||||||
|
|
||||||
(define (make-quit #:exception [exn #f] . actions)
|
(define (make-quit #:exception [exn #f] . actions)
|
||||||
|
@ -263,20 +263,20 @@
|
||||||
[(? quit? q) q]
|
[(? quit? q) q]
|
||||||
[actions (transition state actions)]))
|
[actions (transition state actions)]))
|
||||||
|
|
||||||
(define-syntax-rule (spawn-network boot-action ...)
|
(define-syntax-rule (spawn-dataspace boot-action ...)
|
||||||
(make-spawn-network (lambda () (list boot-action ...))))
|
(make-spawn-dataspace (lambda () (list boot-action ...))))
|
||||||
|
|
||||||
(define (make-network boot-actions)
|
(define (make-dataspace boot-actions)
|
||||||
(network (mux)
|
(dataspace (mux)
|
||||||
(list->queue (for/list ((a (in-list (clean-actions boot-actions)))) (cons 'meta a)))
|
(list->queue (for/list ((a (in-list (clean-actions boot-actions)))) (cons 'meta a)))
|
||||||
(set)
|
(set)
|
||||||
(hash)
|
(hash)
|
||||||
(hash)))
|
(hash)))
|
||||||
|
|
||||||
(define (make-spawn-network boot-actions-thunk)
|
(define (make-spawn-dataspace boot-actions-thunk)
|
||||||
(spawn (lambda ()
|
(spawn (lambda ()
|
||||||
(list network-handle-event
|
(list dataspace-handle-event
|
||||||
(transition (make-network (boot-actions-thunk)) '())))))
|
(transition (make-dataspace (boot-actions-thunk)) '())))))
|
||||||
|
|
||||||
(define (transition-bind k t0)
|
(define (transition-bind k t0)
|
||||||
(match t0
|
(match t0
|
||||||
|
@ -307,10 +307,10 @@
|
||||||
[(? transition? t) (sequence-transitions* t rest)])]))
|
[(? transition? t) (sequence-transitions* t rest)])]))
|
||||||
|
|
||||||
(define (inert? w)
|
(define (inert? w)
|
||||||
(and (queue-empty? (network-pending-action-queue w))
|
(and (queue-empty? (dataspace-pending-action-queue w))
|
||||||
(set-empty? (network-runnable-pids w))))
|
(set-empty? (dataspace-runnable-pids w))))
|
||||||
|
|
||||||
(define (network-handle-event e w)
|
(define (dataspace-handle-event e w)
|
||||||
(if (or e (not (inert? w)))
|
(if (or e (not (inert? w)))
|
||||||
(sequence-transitions (transition w '())
|
(sequence-transitions (transition w '())
|
||||||
(inject-event e)
|
(inject-event e)
|
||||||
|
@ -326,8 +326,8 @@
|
||||||
'()))
|
'()))
|
||||||
|
|
||||||
(define (perform-actions w)
|
(define (perform-actions w)
|
||||||
(for/fold ([wt (transition (struct-copy network w [pending-action-queue (make-queue)]) '())])
|
(for/fold ([wt (transition (struct-copy dataspace w [pending-action-queue (make-queue)]) '())])
|
||||||
((entry (in-list (queue->list (network-pending-action-queue w)))))
|
((entry (in-list (queue->list (dataspace-pending-action-queue w)))))
|
||||||
#:break (quit? wt) ;; TODO: should a quit action be delayed until the end of the turn?
|
#:break (quit? wt) ;; TODO: should a quit action be delayed until the end of the turn?
|
||||||
(match-define [cons label a] entry)
|
(match-define [cons label a] entry)
|
||||||
(trace-internal-action label a (transition-state wt))
|
(trace-internal-action label a (transition-state wt))
|
||||||
|
@ -351,20 +351,20 @@
|
||||||
(match-define (list behavior initial-transition) results)
|
(match-define (list behavior initial-transition) results)
|
||||||
(create-process w behavior initial-transition))
|
(create-process w behavior initial-transition))
|
||||||
(lambda (exn)
|
(lambda (exn)
|
||||||
(log-error "Spawned process in network ~a died with exception:\n~a"
|
(log-error "Spawned process in dataspace ~a died with exception:\n~a"
|
||||||
(trace-pid-stack)
|
(trace-pid-stack)
|
||||||
(exn->string exn))
|
(exn->string exn))
|
||||||
(transition w '())))]
|
(transition w '())))]
|
||||||
['quit
|
['quit
|
||||||
(define-values (new-mux _label s aggregate-assertions)
|
(define-values (new-mux _label s aggregate-assertions)
|
||||||
(mux-remove-stream (network-mux w) label))
|
(mux-remove-stream (dataspace-mux w) label))
|
||||||
;; behavior & state in w already removed by disable-process
|
;; behavior & state in w already removed by disable-process
|
||||||
(deliver-scns w new-mux label s aggregate-assertions)]
|
(deliver-scns w new-mux label s aggregate-assertions)]
|
||||||
[(quit-network)
|
[(quit-dataspace)
|
||||||
(make-quit)]
|
(make-quit)]
|
||||||
[(? scn? s-orig)
|
[(? scn? s-orig)
|
||||||
(define-values (new-mux _label s aggregate-assertions)
|
(define-values (new-mux _label s aggregate-assertions)
|
||||||
(mux-update-stream (network-mux w) label s-orig))
|
(mux-update-stream (dataspace-mux w) label s-orig))
|
||||||
(deliver-scns w new-mux label s aggregate-assertions)]
|
(deliver-scns w new-mux label s aggregate-assertions)]
|
||||||
[(and m (message body))
|
[(and m (message body))
|
||||||
(when (observe? body)
|
(when (observe? body)
|
||||||
|
@ -375,7 +375,7 @@
|
||||||
(at-meta? body)) ;; it relates to envt, not local
|
(at-meta? body)) ;; it relates to envt, not local
|
||||||
(transition w (message (at-meta-claim body)))
|
(transition w (message (at-meta-claim body)))
|
||||||
(transition (for/fold [(w w)]
|
(transition (for/fold [(w w)]
|
||||||
[(pid (in-list (mux-route-message (network-mux w) body)))]
|
[(pid (in-list (mux-route-message (dataspace-mux w) body)))]
|
||||||
(send-event m pid w))
|
(send-event m pid w))
|
||||||
'()))]))
|
'()))]))
|
||||||
|
|
||||||
|
@ -400,20 +400,20 @@
|
||||||
[(cons (? scn? s) rest) (values s rest)]
|
[(cons (? scn? s) rest) (values s rest)]
|
||||||
[other (values (scn trie-empty) other)]))
|
[other (values (scn trie-empty) other)]))
|
||||||
(define-values (new-mux new-pid s aggregate-assertions)
|
(define-values (new-mux new-pid s aggregate-assertions)
|
||||||
(mux-add-stream (network-mux w) initial-scn))
|
(mux-add-stream (dataspace-mux w) initial-scn))
|
||||||
(let* ((w (struct-copy network w
|
(let* ((w (struct-copy dataspace w
|
||||||
[behaviors (hash-set (network-behaviors w)
|
[behaviors (hash-set (dataspace-behaviors w)
|
||||||
new-pid
|
new-pid
|
||||||
behavior)]))
|
behavior)]))
|
||||||
(w (enqueue-actions (postprocess w new-pid) new-pid remaining-initial-actions)))
|
(w (enqueue-actions (postprocess w new-pid) new-pid remaining-initial-actions)))
|
||||||
(deliver-scns w new-mux new-pid s aggregate-assertions)))))
|
(deliver-scns w new-mux new-pid s aggregate-assertions)))))
|
||||||
|
|
||||||
(define (deliver-scns w new-mux acting-label s aggregate-assertions)
|
(define (deliver-scns w new-mux acting-label s aggregate-assertions)
|
||||||
(define old-mux (network-mux w))
|
(define old-mux (dataspace-mux w))
|
||||||
(define old-echo-cancelled-assertions (echo-cancelled-routing-table old-mux))
|
(define old-echo-cancelled-assertions (echo-cancelled-routing-table old-mux))
|
||||||
(define-values (scns meta-action)
|
(define-values (scns meta-action)
|
||||||
(compute-scns old-mux new-mux acting-label s aggregate-assertions))
|
(compute-scns old-mux new-mux acting-label s aggregate-assertions))
|
||||||
(transition (for/fold [(w (struct-copy network w [mux new-mux]))]
|
(transition (for/fold [(w (struct-copy dataspace w [mux new-mux]))]
|
||||||
[(entry (in-list scns))]
|
[(entry (in-list scns))]
|
||||||
(match-define (cons label (and event (scn new-assertions))) entry)
|
(match-define (cons label (and event (scn new-assertions))) entry)
|
||||||
(if (equal? (biased-intersection old-echo-cancelled-assertions
|
(if (equal? (biased-intersection old-echo-cancelled-assertions
|
||||||
|
@ -424,17 +424,17 @@
|
||||||
meta-action))
|
meta-action))
|
||||||
|
|
||||||
(define (step-children w)
|
(define (step-children w)
|
||||||
(define runnable-pids (network-runnable-pids w))
|
(define runnable-pids (dataspace-runnable-pids w))
|
||||||
(if (set-empty? runnable-pids)
|
(if (set-empty? runnable-pids)
|
||||||
#f ;; network is inert.
|
#f ;; dataspace is inert.
|
||||||
(transition (for/fold [(w (struct-copy network w [runnable-pids (set)]))]
|
(transition (for/fold [(w (struct-copy dataspace w [runnable-pids (set)]))]
|
||||||
[(pid (in-set runnable-pids))]
|
[(pid (in-set runnable-pids))]
|
||||||
(send-event #f pid w))
|
(send-event #f pid w))
|
||||||
'())))
|
'())))
|
||||||
|
|
||||||
(define (pretty-print-network w [p (current-output-port)])
|
(define (pretty-print-dataspace w [p (current-output-port)])
|
||||||
(match-define (network mux qs runnable behaviors states) w)
|
(match-define (dataspace mux qs runnable behaviors states) w)
|
||||||
(fprintf p "NETWORK:\n")
|
(fprintf p "DATASPACE:\n")
|
||||||
(fprintf p " - ~a queued actions\n" (queue-length qs))
|
(fprintf p " - ~a queued actions\n" (queue-length qs))
|
||||||
(fprintf p " - ~a runnable pids ~a\n" (set-count runnable) (set->list runnable))
|
(fprintf p " - ~a runnable pids ~a\n" (set-count runnable) (set->list runnable))
|
||||||
(fprintf p " - ~a live processes\n" (hash-count states))
|
(fprintf p " - ~a live processes\n" (hash-count states))
|
||||||
|
@ -460,10 +460,10 @@
|
||||||
(define (step* w)
|
(define (step* w)
|
||||||
(let loop ((w w) (actions '()))
|
(let loop ((w w) (actions '()))
|
||||||
(pretty-print w)
|
(pretty-print w)
|
||||||
(match (network-handle-event #f w)
|
(match (dataspace-handle-event #f w)
|
||||||
[#f (values w #f (flatten actions))]
|
[#f (values w #f (flatten actions))]
|
||||||
[(quit exn new-actions) (values w exn (flatten (cons actions new-actions)))]
|
[(quit exn new-actions) (values w exn (flatten (cons actions new-actions)))]
|
||||||
[(transition new-w new-actions) (loop new-w (cons actions new-actions))])))
|
[(transition new-w new-actions) (loop new-w (cons actions new-actions))])))
|
||||||
|
|
||||||
(step* (make-network '()))
|
(step* (make-dataspace '()))
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#f)]
|
#f)]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
|
|
||||||
(spawn-network (spawn r (void) (scn (subscription ?)))
|
(spawn-dataspace (spawn r (void) (scn (subscription ?)))
|
||||||
(spawn b 0 '()))
|
(spawn b 0 '()))
|
||||||
|
|
||||||
(define (echoer e s)
|
(define (echoer e s)
|
||||||
(match e
|
(match e
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
(subscription 'die)
|
(subscription 'die)
|
||||||
(subscription (observe 'die))))
|
(subscription (observe 'die))))
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
[(message (at-meta 'die)) (quit)]
|
[(message (at-meta 'die)) (quit)]
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
(require syndicate/pretty)
|
(require syndicate/pretty)
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e counter)
|
(spawn (lambda (e counter)
|
||||||
(and e
|
(and e
|
||||||
(let ((new-counter (+ counter 1)))
|
(let ((new-counter (+ counter 1)))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
(require syndicate/pretty)
|
(require syndicate/pretty)
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e counter)
|
(spawn (lambda (e counter)
|
||||||
(and e
|
(and e
|
||||||
(let ((new-counter (+ counter 1)))
|
(let ((new-counter (+ counter 1)))
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
1
|
1
|
||||||
(scn/union (subscription (observe (set-timer ? ? ?)))
|
(scn/union (subscription (observe (set-timer ? ? ?)))
|
||||||
(subscription (timer-expired 'tick ?))))
|
(subscription (timer-expired 'tick ?))))
|
||||||
(spawn-network (spawn r (void) (scn (subscription ?)))
|
(spawn-dataspace (spawn r (void) (scn (subscription ?)))
|
||||||
(spawn b 0 '()))
|
(spawn b 0 '()))
|
||||||
(spawn echoer
|
(spawn echoer
|
||||||
(void)
|
(void)
|
||||||
(scn (subscription (external-event (read-line-evt (current-input-port) 'any) ?)
|
(scn (subscription (external-event (read-line-evt (current-input-port) 'any) ?)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#lang syndicate-monolithic
|
#lang syndicate-monolithic
|
||||||
;; Demonstrates quit-network.
|
;; Demonstrates quit-dataspace.
|
||||||
|
|
||||||
(require (only-in racket/port read-bytes-line-evt))
|
(require (only-in racket/port read-bytes-line-evt))
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
[(message (at-meta (at-meta (external-event _ (list #"quit")))))
|
[(message (at-meta (at-meta (external-event _ (list #"quit")))))
|
||||||
(printf "Quitting just the leaf actor.\n")
|
(printf "Quitting just the leaf actor.\n")
|
||||||
(quit)]
|
(quit)]
|
||||||
[(message (at-meta (at-meta (external-event _ (list #"quit-network")))))
|
[(message (at-meta (at-meta (external-event _ (list #"quit-dataspace")))))
|
||||||
(printf "Terminating the whole network.\n")
|
(printf "Terminating the whole dataspace.\n")
|
||||||
(transition s (quit-network))]
|
(transition s (quit-dataspace))]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
(void)
|
(void)
|
||||||
(scn (subscription (external-event (read-bytes-line-evt (current-input-port) 'any) ?)
|
(scn (subscription (external-event (read-bytes-line-evt (current-input-port) 'any) ?)
|
||||||
|
@ -30,6 +30,6 @@
|
||||||
(void)
|
(void)
|
||||||
(sub-to-alarm)))
|
(sub-to-alarm)))
|
||||||
|
|
||||||
(printf "Type 'quit' or 'quit-network'.\n")
|
(printf "Type 'quit' or 'quit-dataspace'.\n")
|
||||||
(spawn-network (spawn-command-listener)
|
(spawn-dataspace (spawn-command-listener)
|
||||||
(spawn-ticker))
|
(spawn-ticker))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
;; Breaking the infinite tower of nested Networks, connecting to the "real world" at the fracture line.
|
;; Breaking the infinite tower of nested Dataspaces, connecting to the "real world" at the fracture line.
|
||||||
|
|
||||||
(require racket/async-channel)
|
(require racket/async-channel)
|
||||||
(require racket/set)
|
(require racket/set)
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
;; Projection
|
;; Projection
|
||||||
;; Used to extract event descriptors and results from subscriptions
|
;; Used to extract event descriptors and results from subscriptions
|
||||||
;; from the ground VM's contained Network.
|
;; from the ground VM's contained Dataspace.
|
||||||
(define event-projection (observe (external-event (?!) ?)))
|
(define event-projection (observe (external-event (?!) ?)))
|
||||||
|
|
||||||
;; Interests -> (Listof RacketEvent)
|
;; Interests -> (Listof RacketEvent)
|
||||||
|
@ -74,10 +74,10 @@
|
||||||
(handle-evt (system-idle-evt) (lambda _ #f)))
|
(handle-evt (system-idle-evt) (lambda _ #f)))
|
||||||
|
|
||||||
;; Action* -> Void
|
;; Action* -> Void
|
||||||
;; Runs a ground VM, booting the outermost Network with the given Actions.
|
;; Runs a ground VM, booting the outermost Dataspace with the given Actions.
|
||||||
(define (run-ground . boot-actions)
|
(define (run-ground . boot-actions)
|
||||||
(let await-interrupt ((inert? #f)
|
(let await-interrupt ((inert? #f)
|
||||||
(w (make-network boot-actions))
|
(w (make-dataspace boot-actions))
|
||||||
(interests trie-empty))
|
(interests trie-empty))
|
||||||
;; (log-info "GROUND INTERESTS:\n~a" (trie->pretty-string interests))
|
;; (log-info "GROUND INTERESTS:\n~a" (trie->pretty-string interests))
|
||||||
(if (and inert? (trie-empty? interests))
|
(if (and inert? (trie-empty? interests))
|
||||||
|
@ -87,9 +87,9 @@
|
||||||
(current-ground-event-async-channel)
|
(current-ground-event-async-channel)
|
||||||
(if inert? never-evt idle-handler)
|
(if inert? never-evt idle-handler)
|
||||||
(extract-active-events interests))))
|
(extract-active-events interests))))
|
||||||
(trace-process-step e #f network-handle-event w)
|
(trace-process-step e #f dataspace-handle-event w)
|
||||||
(define resulting-transition (clean-transition (network-handle-event e w)))
|
(define resulting-transition (clean-transition (dataspace-handle-event e w)))
|
||||||
(trace-process-step-result e #f network-handle-event w #f resulting-transition)
|
(trace-process-step-result e #f dataspace-handle-event w #f resulting-transition)
|
||||||
(match resulting-transition
|
(match resulting-transition
|
||||||
[#f ;; inert
|
[#f ;; inert
|
||||||
(await-interrupt #t w interests)]
|
(await-interrupt #t w interests)]
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
(define show-message-actions? #f)
|
(define show-message-actions? #f)
|
||||||
(define show-actions? #f)
|
(define show-actions? #f)
|
||||||
(define show-routing-table? #f)
|
(define show-routing-table? #f)
|
||||||
(define network-is-boring? #t)
|
(define dataspace-is-boring? #t)
|
||||||
|
|
||||||
(define (set-stderr-trace-flags! flags-string)
|
(define (set-stderr-trace-flags! flags-string)
|
||||||
(set! flags (for/set [(c flags-string)] (string->symbol (string c))))
|
(set! flags (for/set [(c flags-string)] (string->symbol (string c))))
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
(set-flag! M show-message-actions?)
|
(set-flag! M show-message-actions?)
|
||||||
(set-flag! a show-actions?)
|
(set-flag! a show-actions?)
|
||||||
(set-flag! g show-routing-table?)
|
(set-flag! g show-routing-table?)
|
||||||
(set! network-is-boring? (not (set-member? flags 'N))))
|
(set! dataspace-is-boring? (not (set-member? flags 'N))))
|
||||||
|
|
||||||
(set-stderr-trace-flags! (or (getenv "MINIMART_TRACE") ""))
|
(set-stderr-trace-flags! (or (getenv "MINIMART_TRACE") ""))
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
(apply fprintf (current-error-port) fmt args))
|
(apply fprintf (current-error-port) fmt args))
|
||||||
|
|
||||||
(define (boring-state? state)
|
(define (boring-state? state)
|
||||||
(or (and (network? state) network-is-boring?)
|
(or (and (dataspace? state) dataspace-is-boring?)
|
||||||
(void? state)))
|
(void? state)))
|
||||||
|
|
||||||
(define (set-color! c) (when colored-output? (output "\e[0~am" c)))
|
(define (set-color! c) (when colored-output? (output "\e[0~am" c)))
|
||||||
|
@ -162,14 +162,14 @@
|
||||||
(syndicate-pretty-print (transition-state t) (current-error-port)))))))]
|
(syndicate-pretty-print (transition-state t) (current-error-port)))))))]
|
||||||
[('internal-action (list pids a old-w))
|
[('internal-action (list pids a old-w))
|
||||||
(define pidstr (format-pids pids))
|
(define pidstr (format-pids pids))
|
||||||
(define oldcount (hash-count (network-behaviors old-w)))
|
(define oldcount (hash-count (dataspace-behaviors old-w)))
|
||||||
(match a
|
(match a
|
||||||
[(? spawn?)
|
[(? spawn?)
|
||||||
;; Handle this in internal-action-result
|
;; Handle this in internal-action-result
|
||||||
(void)]
|
(void)]
|
||||||
['quit
|
['quit
|
||||||
(when (or show-process-lifecycle? show-actions?)
|
(when (or show-process-lifecycle? show-actions?)
|
||||||
(define interests (mux-interests-of (network-mux old-w) (car pids)))
|
(define interests (mux-interests-of (dataspace-mux old-w) (car pids)))
|
||||||
(with-color BRIGHT-RED
|
(with-color BRIGHT-RED
|
||||||
(output "~a exiting (~a total processes remain)\n"
|
(output "~a exiting (~a total processes remain)\n"
|
||||||
pidstr
|
pidstr
|
||||||
|
@ -177,9 +177,9 @@
|
||||||
(unless (trie-empty? interests)
|
(unless (trie-empty? interests)
|
||||||
(output "~a's final interests:\n" pidstr)
|
(output "~a's final interests:\n" pidstr)
|
||||||
(pretty-print-trie interests (current-error-port))))]
|
(pretty-print-trie interests (current-error-port))))]
|
||||||
[(quit-network)
|
[(quit-dataspace)
|
||||||
(with-color BRIGHT-RED
|
(with-color BRIGHT-RED
|
||||||
(output "Process ~a performed a quit-network.\n" pidstr))]
|
(output "Process ~a performed a quit-dataspace.\n" pidstr))]
|
||||||
[(scn r)
|
[(scn r)
|
||||||
(when (or show-actions? show-scn-actions?)
|
(when (or show-actions? show-scn-actions?)
|
||||||
(output "~a performing a SCN:\n" pidstr)
|
(output "~a performing a SCN:\n" pidstr)
|
||||||
|
@ -192,15 +192,15 @@
|
||||||
(when (transition? t)
|
(when (transition? t)
|
||||||
(define new-w (transition-state t))
|
(define new-w (transition-state t))
|
||||||
(define pidstr (format-pids pids))
|
(define pidstr (format-pids pids))
|
||||||
(define newcount (hash-count (network-behaviors new-w)))
|
(define newcount (hash-count (dataspace-behaviors new-w)))
|
||||||
(match a
|
(match a
|
||||||
[(? spawn?)
|
[(? spawn?)
|
||||||
(when (or show-process-lifecycle? show-actions?)
|
(when (or show-process-lifecycle? show-actions?)
|
||||||
(define newpid (mux-next-pid (network-mux old-w)))
|
(define newpid (mux-next-pid (dataspace-mux old-w)))
|
||||||
(define newpidstr (format-pids (cons newpid (cdr pids)))) ;; replace parent pid
|
(define newpidstr (format-pids (cons newpid (cdr pids)))) ;; replace parent pid
|
||||||
(define interests (mux-interests-of (network-mux new-w) newpid))
|
(define interests (mux-interests-of (dataspace-mux new-w) newpid))
|
||||||
(define behavior (hash-ref (network-behaviors new-w) newpid '#:missing-behavior))
|
(define behavior (hash-ref (dataspace-behaviors new-w) newpid '#:missing-behavior))
|
||||||
(define state (hash-ref (network-states new-w) newpid '#:missing-state))
|
(define state (hash-ref (dataspace-states new-w) newpid '#:missing-state))
|
||||||
(with-color BRIGHT-GREEN
|
(with-color BRIGHT-GREEN
|
||||||
(output "~a ~v spawned from ~a (~a total processes now)\n"
|
(output "~a ~v spawned from ~a (~a total processes now)\n"
|
||||||
newpidstr
|
newpidstr
|
||||||
|
@ -217,8 +217,8 @@
|
||||||
;; other cases handled in internal-action
|
;; other cases handled in internal-action
|
||||||
(void)])
|
(void)])
|
||||||
(when show-routing-table?
|
(when show-routing-table?
|
||||||
(define old-table (mux-routing-table (network-mux old-w)))
|
(define old-table (mux-routing-table (dataspace-mux old-w)))
|
||||||
(define new-table (mux-routing-table (network-mux new-w)))
|
(define new-table (mux-routing-table (dataspace-mux new-w)))
|
||||||
(when (not (equal? old-table new-table))
|
(when (not (equal? old-table new-table))
|
||||||
(with-color BRIGHT-BLUE
|
(with-color BRIGHT-BLUE
|
||||||
(output "~a's routing table:\n" (format-pids (cdr pids)))
|
(output "~a's routing table:\n" (format-pids (cdr pids)))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(provide actor
|
(provide actor
|
||||||
network
|
dataspace
|
||||||
;; background
|
;; background
|
||||||
state
|
state
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
(require racket/set)
|
(require racket/set)
|
||||||
(require racket/match)
|
(require racket/match)
|
||||||
|
|
||||||
(require (except-in "core.rkt" assert network)
|
(require (except-in "core.rkt" assert dataspace)
|
||||||
(rename-in "core.rkt" [assert core:assert] [network core:network]))
|
(rename-in "core.rkt" [assert core:assert] [dataspace core:dataspace]))
|
||||||
(require "trie.rkt")
|
(require "trie.rkt")
|
||||||
(require "mux.rkt")
|
(require "mux.rkt")
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
;; A LinkageKind is one of
|
;; A LinkageKind is one of
|
||||||
;; - 'call, a blocking, exception-linked connection
|
;; - 'call, a blocking, exception-linked connection
|
||||||
;; - 'actor, a non-blocking, non-exception-linked connection
|
;; - 'actor, a non-blocking, non-exception-linked connection
|
||||||
;; - 'network, a non-blocking, nested, non-exception-linked connection
|
;; - 'dataspace, a non-blocking, nested, non-exception-linked connection
|
||||||
;;
|
;;
|
||||||
;; Patch Instructions are issued when the actor uses `assert!` and
|
;; Patch Instructions are issued when the actor uses `assert!` and
|
||||||
;; `retract!`. Action instructions are issued when the actor uses
|
;; `retract!`. Action instructions are issued when the actor uses
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
;; called. Script-complete instructions are automatically issued when
|
;; called. Script-complete instructions are automatically issued when
|
||||||
;; a Script terminates successfully.
|
;; a Script terminates successfully.
|
||||||
;;
|
;;
|
||||||
;; Spawn instructions are issued when `actor`, `network`, and `state`
|
;; Spawn instructions are issued when `actor`, `dataspace`, and `state`
|
||||||
;; are used, directly or indirectly. (TODO: `background`?) The
|
;; are used, directly or indirectly. (TODO: `background`?) The
|
||||||
;; spawn-action-producing function is given the IDs of the spawned and
|
;; spawn-action-producing function is given the IDs of the spawned and
|
||||||
;; spawning actors, and is to return an action which spawns the new
|
;; spawning actors, and is to return an action which spawns the new
|
||||||
|
@ -256,14 +256,14 @@
|
||||||
[(_ I ...)
|
[(_ I ...)
|
||||||
(expand-state 'actor #'(I ... (return/no-link-result!)) #'() #'() #'() #'())]))
|
(expand-state 'actor #'(I ... (return/no-link-result!)) #'() #'() #'() #'())]))
|
||||||
|
|
||||||
;; Spawn whole networks
|
;; Spawn whole dataspaces
|
||||||
(define-syntax (network stx)
|
(define-syntax (dataspace stx)
|
||||||
(syntax-parse stx
|
(syntax-parse stx
|
||||||
[(_ I ...)
|
[(_ I ...)
|
||||||
(expand-state 'network
|
(expand-state 'dataspace
|
||||||
#'(I
|
#'(I
|
||||||
...
|
...
|
||||||
(perform-core-action! (quit-network))
|
(perform-core-action! (quit-dataspace))
|
||||||
(return/no-link-result!))
|
(return/no-link-result!))
|
||||||
#'()
|
#'()
|
||||||
#'()
|
#'()
|
||||||
|
@ -393,8 +393,8 @@
|
||||||
(transition (if blocking?
|
(transition (if blocking?
|
||||||
(store-continuation s callee-id get-next-instr)
|
(store-continuation s callee-id get-next-instr)
|
||||||
s)
|
s)
|
||||||
(if (eq? linkage-kind 'network)
|
(if (eq? linkage-kind 'dataspace)
|
||||||
(spawn-network spawn-action)
|
(spawn-dataspace spawn-action)
|
||||||
spawn-action)))))
|
spawn-action)))))
|
||||||
(if blocking?
|
(if blocking?
|
||||||
next-t
|
next-t
|
||||||
|
@ -415,7 +415,7 @@
|
||||||
|
|
||||||
;; TODO: track
|
;; TODO: track
|
||||||
;; TODO: default to hll
|
;; TODO: default to hll
|
||||||
;; TODO: some better means of keeping track of nested network levels
|
;; TODO: some better means of keeping track of nested dataspace levels
|
||||||
|
|
||||||
(begin-for-syntax
|
(begin-for-syntax
|
||||||
(define-splicing-syntax-class when-pred
|
(define-splicing-syntax-class when-pred
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(provide big-bang-network
|
(provide big-bang-dataspace
|
||||||
big-bang-network/universe
|
big-bang-dataspace/universe
|
||||||
(struct-out window)
|
(struct-out window)
|
||||||
(struct-out to-server)
|
(struct-out to-server)
|
||||||
(struct-out from-server)
|
(struct-out from-server)
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
;;---------------------------------------------------------------------------
|
||||||
|
|
||||||
(struct bb (network windows inbound outbound halted? x y) #:transparent)
|
(struct bb (dataspace windows inbound outbound halted? x y) #:transparent)
|
||||||
|
|
||||||
(define window-projection (?! (window ? ? ? ? ?)))
|
(define window-projection (?! (window ? ? ? ? ?)))
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
#f)]))
|
#f)]))
|
||||||
|
|
||||||
(define (deliver b e)
|
(define (deliver b e)
|
||||||
(clean-transition (network-handle-event e (bb-network b))))
|
(clean-transition (dataspace-handle-event e (bb-dataspace b))))
|
||||||
|
|
||||||
(define (interpret-actions b txn need-poll?)
|
(define (interpret-actions b txn need-poll?)
|
||||||
(match txn
|
(match txn
|
||||||
|
@ -90,8 +90,8 @@
|
||||||
[(cons e rest)
|
[(cons e rest)
|
||||||
(let ((b (struct-copy bb b [inbound rest])))
|
(let ((b (struct-copy bb b [inbound rest])))
|
||||||
(interpret-actions b (deliver b e) #t))])]
|
(interpret-actions b (deliver b e) #t))])]
|
||||||
[(transition new-network actions)
|
[(transition new-dataspace actions)
|
||||||
(let process-actions ((b (struct-copy bb b [network new-network])) (actions actions))
|
(let process-actions ((b (struct-copy bb b [dataspace new-dataspace])) (actions actions))
|
||||||
(match actions
|
(match actions
|
||||||
['() (interpret-actions b #f #t)]
|
['() (interpret-actions b #f #t)]
|
||||||
[(cons a actions)
|
[(cons a actions)
|
||||||
|
@ -128,8 +128,8 @@
|
||||||
(patch-seq (retract (active-window ?))
|
(patch-seq (retract (active-window ?))
|
||||||
(assert (active-window active-id))))
|
(assert (active-window active-id))))
|
||||||
|
|
||||||
(define-syntax-rule (big-bang-network* boot-actions extra-clause ...)
|
(define-syntax-rule (big-bang-dataspace* boot-actions extra-clause ...)
|
||||||
(big-bang (interpret-actions (bb (make-network boot-actions)
|
(big-bang (interpret-actions (bb (make-dataspace boot-actions)
|
||||||
'()
|
'()
|
||||||
'()
|
'()
|
||||||
'()
|
'()
|
||||||
|
@ -155,25 +155,25 @@
|
||||||
(stop-when bb-halted?)
|
(stop-when bb-halted?)
|
||||||
extra-clause ...))
|
extra-clause ...))
|
||||||
|
|
||||||
(define-syntax-rule (big-bang-network** width height boot-actions extra-clause ...)
|
(define-syntax-rule (big-bang-dataspace** width height boot-actions extra-clause ...)
|
||||||
(if (and width height)
|
(if (and width height)
|
||||||
(big-bang-network* boot-actions (to-draw render width height) extra-clause ...)
|
(big-bang-dataspace* boot-actions (to-draw render width height) extra-clause ...)
|
||||||
(big-bang-network* boot-actions (to-draw render) extra-clause ...)))
|
(big-bang-dataspace* boot-actions (to-draw render) extra-clause ...)))
|
||||||
|
|
||||||
(define (big-bang-network #:width [width #f]
|
(define (big-bang-dataspace #:width [width #f]
|
||||||
#:height [height #f]
|
#:height [height #f]
|
||||||
. boot-actions)
|
. boot-actions)
|
||||||
(big-bang-network** width height boot-actions))
|
(big-bang-dataspace** width height boot-actions))
|
||||||
|
|
||||||
(define (big-bang-network/universe #:width [width #f]
|
(define (big-bang-dataspace/universe #:width [width #f]
|
||||||
#:height [height #f]
|
#:height [height #f]
|
||||||
#:register [ip LOCALHOST]
|
#:register [ip LOCALHOST]
|
||||||
#:port [port-number SQPORT]
|
#:port [port-number SQPORT]
|
||||||
#:name [world-name (gensym 'syndicate)]
|
#:name [world-name (gensym 'syndicate)]
|
||||||
. boot-actions)
|
. boot-actions)
|
||||||
(big-bang-network** width height boot-actions
|
(big-bang-dataspace** width height boot-actions
|
||||||
(on-receive (lambda (b sexps)
|
(on-receive (lambda (b sexps)
|
||||||
(inject b (for/list ((m sexps)) (message (from-server m))))))
|
(inject b (for/list ((m sexps)) (message (from-server m))))))
|
||||||
(register ip)
|
(register ip)
|
||||||
(port port-number)
|
(port port-number)
|
||||||
(name world-name)))
|
(name world-name)))
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
;; Core implementation of Incremental Network Calculus.
|
;; Core implementation of Incremental Syndicate.
|
||||||
|
|
||||||
(provide (struct-out message)
|
(provide (struct-out message)
|
||||||
(except-out (struct-out quit) quit)
|
(except-out (struct-out quit) quit)
|
||||||
(struct-out quit-network)
|
(struct-out quit-dataspace)
|
||||||
(rename-out [quit <quit>])
|
(rename-out [quit <quit>])
|
||||||
(except-out (struct-out spawn) spawn)
|
(except-out (struct-out spawn) spawn)
|
||||||
(rename-out [spawn <spawn>])
|
(rename-out [spawn <spawn>])
|
||||||
(struct-out transition)
|
(struct-out transition)
|
||||||
(struct-out network)
|
(struct-out dataspace)
|
||||||
|
|
||||||
(struct-out seal)
|
(struct-out seal)
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@
|
||||||
unpub
|
unpub
|
||||||
|
|
||||||
(rename-out [make-quit quit])
|
(rename-out [make-quit quit])
|
||||||
make-network
|
make-dataspace
|
||||||
spawn-network
|
spawn-dataspace
|
||||||
(rename-out [spawn-process spawn])
|
(rename-out [spawn-process spawn])
|
||||||
spawn/stateless
|
spawn/stateless
|
||||||
make-spawn-network
|
make-spawn-dataspace
|
||||||
|
|
||||||
transition-bind
|
transition-bind
|
||||||
sequence-transitions
|
sequence-transitions
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
sequence-transitions0
|
sequence-transitions0
|
||||||
sequence-transitions0*
|
sequence-transitions0*
|
||||||
|
|
||||||
network-handle-event
|
dataspace-handle-event
|
||||||
clean-transition
|
clean-transition
|
||||||
|
|
||||||
pretty-print-network)
|
pretty-print-dataspace)
|
||||||
|
|
||||||
(require racket/set)
|
(require racket/set)
|
||||||
(require racket/match)
|
(require racket/match)
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
;; Actions ⊃ Events
|
;; Actions ⊃ Events
|
||||||
(struct spawn (boot) #:prefab)
|
(struct spawn (boot) #:prefab)
|
||||||
(struct quit-network () #:prefab) ;; NB. An action. Compare (quit), a Transition.
|
(struct quit-dataspace () #:prefab) ;; NB. An action. Compare (quit), a Transition.
|
||||||
|
|
||||||
;; A Behavior is a ((Option Event) Any -> Transition): a function
|
;; A Behavior is a ((Option Event) Any -> Transition): a function
|
||||||
;; mapping an Event (or, in the #f case, a poll signal) and a
|
;; mapping an Event (or, in the #f case, a poll signal) and a
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
;; - #f, a signal from a Process that it is inert and need not be
|
;; - #f, a signal from a Process that it is inert and need not be
|
||||||
;; scheduled until some Event relevant to it arrives; or,
|
;; scheduled until some Event relevant to it arrives; or,
|
||||||
;; - a (transition Any (Constreeof Action)), a new Process state to
|
;; - a (transition Any (Constreeof Action)), a new Process state to
|
||||||
;; be held by its Network and a sequence of Actions for the Network
|
;; be held by its Dataspace and a sequence of Actions for the Dataspace
|
||||||
;; to take on the transitioning Process's behalf.
|
;; to take on the transitioning Process's behalf.
|
||||||
;; - a (quit (Option Exn) (Constreeof Action)), signalling that the
|
;; - a (quit (Option Exn) (Constreeof Action)), signalling that the
|
||||||
;; Process should never again be handed an event, and that any
|
;; Process should never again be handed an event, and that any
|
||||||
|
@ -104,16 +104,16 @@
|
||||||
;; A Label is a PID or 'meta.
|
;; A Label is a PID or 'meta.
|
||||||
|
|
||||||
;; VM private states
|
;; VM private states
|
||||||
(struct network (mux ;; Multiplexer
|
(struct dataspace (mux ;; Multiplexer
|
||||||
pending-action-queue ;; (Queueof (Cons Label (U Action 'quit)))
|
pending-action-queue ;; (Queueof (Cons Label (U Action 'quit)))
|
||||||
runnable-pids ;; (Setof PID)
|
runnable-pids ;; (Setof PID)
|
||||||
behaviors ;; (HashTable PID Behavior)
|
behaviors ;; (HashTable PID Behavior)
|
||||||
states ;; (HashTable PID Any)
|
states ;; (HashTable PID Any)
|
||||||
)
|
)
|
||||||
#:transparent
|
#:transparent
|
||||||
#:methods gen:syndicate-pretty-printable
|
#:methods gen:syndicate-pretty-printable
|
||||||
[(define (syndicate-pretty-print w [p (current-output-port)])
|
[(define (syndicate-pretty-print w [p (current-output-port)])
|
||||||
(pretty-print-network w p))])
|
(pretty-print-dataspace w p))])
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Seals are used by protocols to prevent the routing tries from
|
;; Seals are used by protocols to prevent the routing tries from
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define (event? x) (or (patch? x) (message? x)))
|
(define (event? x) (or (patch? x) (message? x)))
|
||||||
(define (action? x) (or (event? x) (spawn? x) (quit-network? x)))
|
(define (action? x) (or (event? x) (spawn? x) (quit-dataspace? x)))
|
||||||
|
|
||||||
(define-syntax-rule (match-event e clause ...)
|
(define-syntax-rule (match-event e clause ...)
|
||||||
(match e
|
(match e
|
||||||
|
@ -178,8 +178,8 @@
|
||||||
(filter (lambda (x) (and (action? x) (not (patch-empty? x)))) (flatten actions)))
|
(filter (lambda (x) (and (action? x) (not (patch-empty? x)))) (flatten actions)))
|
||||||
|
|
||||||
(define (send-event e pid w)
|
(define (send-event e pid w)
|
||||||
(define behavior (hash-ref (network-behaviors w) pid #f))
|
(define behavior (hash-ref (dataspace-behaviors w) pid #f))
|
||||||
(define old-state (hash-ref (network-states w) pid #f))
|
(define old-state (hash-ref (dataspace-states w) pid #f))
|
||||||
(if (not behavior)
|
(if (not behavior)
|
||||||
w
|
w
|
||||||
(begin
|
(begin
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
(enqueue-actions (disable-process pid exn w) pid (list 'quit)))))))
|
(enqueue-actions (disable-process pid exn w) pid (list 'quit)))))))
|
||||||
|
|
||||||
(define (update-state w pid s)
|
(define (update-state w pid s)
|
||||||
(struct-copy network w [states (hash-set (network-states w) pid s)]))
|
(struct-copy dataspace w [states (hash-set (dataspace-states w) pid s)]))
|
||||||
|
|
||||||
(define (send-event/guard delta pid w)
|
(define (send-event/guard delta pid w)
|
||||||
(if (patch-empty? delta)
|
(if (patch-empty? delta)
|
||||||
|
@ -214,9 +214,9 @@
|
||||||
(log-error "Process ~a died with exception:\n~a"
|
(log-error "Process ~a died with exception:\n~a"
|
||||||
(cons pid (trace-pid-stack))
|
(cons pid (trace-pid-stack))
|
||||||
(exn->string exn)))
|
(exn->string exn)))
|
||||||
(struct-copy network w
|
(struct-copy dataspace w
|
||||||
[behaviors (hash-remove (network-behaviors w) pid)]
|
[behaviors (hash-remove (dataspace-behaviors w) pid)]
|
||||||
[states (hash-remove (network-states w) pid)]))
|
[states (hash-remove (dataspace-states w) pid)]))
|
||||||
|
|
||||||
(define (invoke-process pid thunk k-ok k-exn)
|
(define (invoke-process pid thunk k-ok k-exn)
|
||||||
(define-values (ok? result)
|
(define-values (ok? result)
|
||||||
|
@ -230,12 +230,12 @@
|
||||||
(k-exn result)))
|
(k-exn result)))
|
||||||
|
|
||||||
(define (mark-pid-runnable w pid)
|
(define (mark-pid-runnable w pid)
|
||||||
(struct-copy network w [runnable-pids (set-add (network-runnable-pids w) pid)]))
|
(struct-copy dataspace w [runnable-pids (set-add (dataspace-runnable-pids w) pid)]))
|
||||||
|
|
||||||
(define (enqueue-actions w label actions)
|
(define (enqueue-actions w label actions)
|
||||||
(struct-copy network w
|
(struct-copy dataspace w
|
||||||
[pending-action-queue
|
[pending-action-queue
|
||||||
(queue-append-list (network-pending-action-queue w)
|
(queue-append-list (dataspace-pending-action-queue w)
|
||||||
(for/list [(a actions)] (cons label a)))]))
|
(for/list [(a actions)] (cons label a)))]))
|
||||||
|
|
||||||
(define (make-quit #:exception [exn #f] . actions)
|
(define (make-quit #:exception [exn #f] . actions)
|
||||||
|
@ -265,20 +265,20 @@
|
||||||
[(? quit? q) q]
|
[(? quit? q) q]
|
||||||
[actions (transition state actions)]))
|
[actions (transition state actions)]))
|
||||||
|
|
||||||
(define-syntax-rule (spawn-network boot-action ...)
|
(define-syntax-rule (spawn-dataspace boot-action ...)
|
||||||
(make-spawn-network (lambda () (list boot-action ...))))
|
(make-spawn-dataspace (lambda () (list boot-action ...))))
|
||||||
|
|
||||||
(define (make-network boot-actions)
|
(define (make-dataspace boot-actions)
|
||||||
(network (mux)
|
(dataspace (mux)
|
||||||
(list->queue (for/list ((a (in-list (clean-actions boot-actions)))) (cons 'meta a)))
|
(list->queue (for/list ((a (in-list (clean-actions boot-actions)))) (cons 'meta a)))
|
||||||
(set)
|
(set)
|
||||||
(hash)
|
(hash)
|
||||||
(hash)))
|
(hash)))
|
||||||
|
|
||||||
(define (make-spawn-network boot-actions-thunk)
|
(define (make-spawn-dataspace boot-actions-thunk)
|
||||||
(spawn (lambda ()
|
(spawn (lambda ()
|
||||||
(list network-handle-event
|
(list dataspace-handle-event
|
||||||
(transition (make-network (boot-actions-thunk)) '())))))
|
(transition (make-dataspace (boot-actions-thunk)) '())))))
|
||||||
|
|
||||||
(define (transition-bind k t0)
|
(define (transition-bind k t0)
|
||||||
(match t0
|
(match t0
|
||||||
|
@ -309,10 +309,10 @@
|
||||||
[(? transition? t) (sequence-transitions* t rest)])]))
|
[(? transition? t) (sequence-transitions* t rest)])]))
|
||||||
|
|
||||||
(define (inert? w)
|
(define (inert? w)
|
||||||
(and (queue-empty? (network-pending-action-queue w))
|
(and (queue-empty? (dataspace-pending-action-queue w))
|
||||||
(set-empty? (network-runnable-pids w))))
|
(set-empty? (dataspace-runnable-pids w))))
|
||||||
|
|
||||||
(define (network-handle-event e w)
|
(define (dataspace-handle-event e w)
|
||||||
(if (or e (not (inert? w)))
|
(if (or e (not (inert? w)))
|
||||||
(sequence-transitions (transition w '())
|
(sequence-transitions (transition w '())
|
||||||
(inject-event e)
|
(inject-event e)
|
||||||
|
@ -328,8 +328,8 @@
|
||||||
'()))
|
'()))
|
||||||
|
|
||||||
(define (perform-actions w)
|
(define (perform-actions w)
|
||||||
(for/fold ([wt (transition (struct-copy network w [pending-action-queue (make-queue)]) '())])
|
(for/fold ([wt (transition (struct-copy dataspace w [pending-action-queue (make-queue)]) '())])
|
||||||
((entry (in-list (queue->list (network-pending-action-queue w)))))
|
((entry (in-list (queue->list (dataspace-pending-action-queue w)))))
|
||||||
#:break (quit? wt) ;; TODO: should a quit action be delayed until the end of the turn?
|
#:break (quit? wt) ;; TODO: should a quit action be delayed until the end of the turn?
|
||||||
(match-define [cons label a] entry)
|
(match-define [cons label a] entry)
|
||||||
(trace-internal-action label a (transition-state wt))
|
(trace-internal-action label a (transition-state wt))
|
||||||
|
@ -353,20 +353,20 @@
|
||||||
(match-define (list behavior initial-transition) results)
|
(match-define (list behavior initial-transition) results)
|
||||||
(create-process w behavior initial-transition))
|
(create-process w behavior initial-transition))
|
||||||
(lambda (exn)
|
(lambda (exn)
|
||||||
(log-error "Spawned process in network ~a died with exception:\n~a"
|
(log-error "Spawned process in dataspace ~a died with exception:\n~a"
|
||||||
(trace-pid-stack)
|
(trace-pid-stack)
|
||||||
(exn->string exn))
|
(exn->string exn))
|
||||||
(transition w '())))]
|
(transition w '())))]
|
||||||
['quit
|
['quit
|
||||||
(define-values (new-mux _label delta delta-aggregate)
|
(define-values (new-mux _label delta delta-aggregate)
|
||||||
(mux-remove-stream (network-mux w) label))
|
(mux-remove-stream (dataspace-mux w) label))
|
||||||
;; behavior & state in w already removed by disable-process
|
;; behavior & state in w already removed by disable-process
|
||||||
(deliver-patches w new-mux label delta delta-aggregate)]
|
(deliver-patches w new-mux label delta delta-aggregate)]
|
||||||
[(quit-network)
|
[(quit-dataspace)
|
||||||
(make-quit)]
|
(make-quit)]
|
||||||
[(? patch? delta-orig)
|
[(? patch? delta-orig)
|
||||||
(define-values (new-mux _label delta delta-aggregate)
|
(define-values (new-mux _label delta delta-aggregate)
|
||||||
(mux-update-stream (network-mux w) label delta-orig))
|
(mux-update-stream (dataspace-mux w) label delta-orig))
|
||||||
(deliver-patches w new-mux label delta delta-aggregate)]
|
(deliver-patches w new-mux label delta delta-aggregate)]
|
||||||
[(and m (message body))
|
[(and m (message body))
|
||||||
(when (observe? body)
|
(when (observe? body)
|
||||||
|
@ -377,7 +377,7 @@
|
||||||
(at-meta? body)) ;; it relates to envt, not local
|
(at-meta? body)) ;; it relates to envt, not local
|
||||||
(transition w (message (at-meta-claim body)))
|
(transition w (message (at-meta-claim body)))
|
||||||
(transition (for/fold [(w w)]
|
(transition (for/fold [(w w)]
|
||||||
[(pid (in-list (mux-route-message (network-mux w) body)))]
|
[(pid (in-list (mux-route-message (dataspace-mux w) body)))]
|
||||||
(send-event m pid w))
|
(send-event m pid w))
|
||||||
'()))]))
|
'()))]))
|
||||||
|
|
||||||
|
@ -402,9 +402,9 @@
|
||||||
[(cons (? patch? p) rest) (values p rest)]
|
[(cons (? patch? p) rest) (values p rest)]
|
||||||
[other (values patch-empty other)]))
|
[other (values patch-empty other)]))
|
||||||
(define-values (new-mux new-pid delta delta-aggregate)
|
(define-values (new-mux new-pid delta delta-aggregate)
|
||||||
(mux-add-stream (network-mux w) initial-patch))
|
(mux-add-stream (dataspace-mux w) initial-patch))
|
||||||
(let* ((w (struct-copy network w
|
(let* ((w (struct-copy dataspace w
|
||||||
[behaviors (hash-set (network-behaviors w)
|
[behaviors (hash-set (dataspace-behaviors w)
|
||||||
new-pid
|
new-pid
|
||||||
behavior)]))
|
behavior)]))
|
||||||
(w (enqueue-actions (postprocess w new-pid) new-pid remaining-initial-actions)))
|
(w (enqueue-actions (postprocess w new-pid) new-pid remaining-initial-actions)))
|
||||||
|
@ -412,25 +412,25 @@
|
||||||
|
|
||||||
(define (deliver-patches w new-mux acting-label delta delta-aggregate)
|
(define (deliver-patches w new-mux acting-label delta delta-aggregate)
|
||||||
(define-values (patches meta-action)
|
(define-values (patches meta-action)
|
||||||
(compute-patches (network-mux w) new-mux acting-label delta delta-aggregate))
|
(compute-patches (dataspace-mux w) new-mux acting-label delta delta-aggregate))
|
||||||
(transition (for/fold [(w (struct-copy network w [mux new-mux]))]
|
(transition (for/fold [(w (struct-copy dataspace w [mux new-mux]))]
|
||||||
[(entry (in-list patches))]
|
[(entry (in-list patches))]
|
||||||
(match-define (cons label event) entry)
|
(match-define (cons label event) entry)
|
||||||
(send-event/guard event label w))
|
(send-event/guard event label w))
|
||||||
meta-action))
|
meta-action))
|
||||||
|
|
||||||
(define (step-children w)
|
(define (step-children w)
|
||||||
(define runnable-pids (network-runnable-pids w))
|
(define runnable-pids (dataspace-runnable-pids w))
|
||||||
(if (set-empty? runnable-pids)
|
(if (set-empty? runnable-pids)
|
||||||
#f ;; network is inert.
|
#f ;; dataspace is inert.
|
||||||
(transition (for/fold [(w (struct-copy network w [runnable-pids (set)]))]
|
(transition (for/fold [(w (struct-copy dataspace w [runnable-pids (set)]))]
|
||||||
[(pid (in-set runnable-pids))]
|
[(pid (in-set runnable-pids))]
|
||||||
(send-event #f pid w))
|
(send-event #f pid w))
|
||||||
'())))
|
'())))
|
||||||
|
|
||||||
(define (pretty-print-network w [p (current-output-port)])
|
(define (pretty-print-dataspace w [p (current-output-port)])
|
||||||
(match-define (network mux qs runnable behaviors states) w)
|
(match-define (dataspace mux qs runnable behaviors states) w)
|
||||||
(fprintf p "NETWORK:\n")
|
(fprintf p "DATASPACE:\n")
|
||||||
(fprintf p " - ~a queued actions\n" (queue-length qs))
|
(fprintf p " - ~a queued actions\n" (queue-length qs))
|
||||||
(fprintf p " - ~a runnable pids ~a\n" (set-count runnable) (set->list runnable))
|
(fprintf p " - ~a runnable pids ~a\n" (set-count runnable) (set->list runnable))
|
||||||
(fprintf p " - ~a live processes\n" (hash-count states))
|
(fprintf p " - ~a live processes\n" (hash-count states))
|
||||||
|
@ -456,10 +456,10 @@
|
||||||
(define (step* w)
|
(define (step* w)
|
||||||
(let loop ((w w) (actions '()))
|
(let loop ((w w) (actions '()))
|
||||||
(pretty-print w)
|
(pretty-print w)
|
||||||
(match (network-handle-event #f w)
|
(match (dataspace-handle-event #f w)
|
||||||
[#f (values w #f (flatten actions))]
|
[#f (values w #f (flatten actions))]
|
||||||
[(quit exn new-actions) (values w exn (flatten (cons actions new-actions)))]
|
[(quit exn new-actions) (values w exn (flatten (cons actions new-actions)))]
|
||||||
[(transition new-w new-actions) (loop new-w (cons actions new-actions))])))
|
[(transition new-w new-actions) (loop new-w (cons actions new-actions))])))
|
||||||
|
|
||||||
(step* (make-network '()))
|
(step* (make-dataspace '()))
|
||||||
)
|
)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
;; that are coming from the background thread.
|
;; that are coming from the background thread.
|
||||||
;;
|
;;
|
||||||
;; The race cannot occur in the sequential implementation
|
;; The race cannot occur in the sequential implementation
|
||||||
;; because the network makes sure to enqueue the transition
|
;; because the dataspace makes sure to enqueue the transition
|
||||||
;; actions resulting from the set-timer message delivery ahead
|
;; actions resulting from the set-timer message delivery ahead
|
||||||
;; of any enqueueing of the timer-expired ground message, so
|
;; of any enqueueing of the timer-expired ground message, so
|
||||||
;; that by the time the ground message is processed, the
|
;; that by the time the ground message is processed, the
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
(send! (says user (string-trim (bytes->string/utf-8 bs))))))))
|
(send! (says user (string-trim (bytes->string/utf-8 bs))))))))
|
||||||
|
|
||||||
(spawn-tcp-driver)
|
(spawn-tcp-driver)
|
||||||
(network (define us (tcp-listener 5999))
|
(dataspace (define us (tcp-listener 5999))
|
||||||
(forever (assert (advertise (observe (tcp-channel _ us _))) #:meta-level 1)
|
(forever (assert (advertise (observe (tcp-channel _ us _))) #:meta-level 1)
|
||||||
(on (asserted (advertise (tcp-channel $them us _)) #:meta-level 1)
|
(on (asserted (advertise (tcp-channel $them us _)) #:meta-level 1)
|
||||||
(spawn-session them us))))
|
(spawn-session them us))))
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
(assert (advertise (tcp-channel us them _)) #:meta-level 1)
|
(assert (advertise (tcp-channel us them _)) #:meta-level 1)
|
||||||
(on (message (tcp-channel them us $bs) #:meta-level 1)
|
(on (message (tcp-channel them us $bs) #:meta-level 1)
|
||||||
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
||||||
(if (equal? input-string "quit-network")
|
(if (equal? input-string "quit-dataspace")
|
||||||
(send! (shutdown))
|
(send! (shutdown))
|
||||||
(send! (says user input-string)))))))
|
(send! (says user input-string)))))))
|
||||||
|
|
||||||
(spawn-tcp-driver)
|
(spawn-tcp-driver)
|
||||||
(network (define us (tcp-listener 5999))
|
(dataspace (define us (tcp-listener 5999))
|
||||||
(until (message (shutdown))
|
(until (message (shutdown))
|
||||||
(assert (advertise (observe (tcp-channel _ us _))) #:meta-level 1)
|
(assert (advertise (observe (tcp-channel _ us _))) #:meta-level 1)
|
||||||
(on (asserted (advertise (tcp-channel $them us _)) #:meta-level 1)
|
(on (asserted (advertise (tcp-channel $them us _)) #:meta-level 1)
|
||||||
(spawn-session them us))))
|
(spawn-session them us))))
|
||||||
|
|
|
@ -50,21 +50,21 @@
|
||||||
(mouse-sub name)
|
(mouse-sub name)
|
||||||
(move-to orig-x orig-y))))
|
(move-to orig-x orig-y))))
|
||||||
|
|
||||||
(big-bang-network #:width 640
|
(big-bang-dataspace #:width 640
|
||||||
#:height 480
|
#:height 480
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
[(? patch? p)
|
[(? patch? p)
|
||||||
(define-values (in out)
|
(define-values (in out)
|
||||||
(patch-project/set/single p (at-meta (?! (active-window ?)))))
|
(patch-project/set/single p (at-meta (?! (active-window ?)))))
|
||||||
(transition s (update-window 'active-window-label 300 0
|
(transition s (update-window 'active-window-label 300 0
|
||||||
(text (format "~v" in) 22 "black")))]
|
(text (format "~v" in) 22 "black")))]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
(void)
|
(void)
|
||||||
(sub (active-window ?) #:meta-level 1))
|
(sub (active-window ?) #:meta-level 1))
|
||||||
(button #:background "red" 'stop-button 0 0 "Exit"
|
(button #:background "red" 'stop-button 0 0 "Exit"
|
||||||
(lambda () (assert 'stop #:meta-level 1)))
|
(lambda () (assert 'stop #:meta-level 1)))
|
||||||
(draggable-shape 'c1 50 50 (circle 30 "solid" "orange"))
|
(draggable-shape 'c1 50 50 (circle 30 "solid" "orange"))
|
||||||
(draggable-shape 's1 100 100 (star 40 "solid" "firebrick")))
|
(draggable-shape 's1 100 100 (star 40 "solid" "firebrick")))
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(spawn-tcp-driver)
|
(spawn-tcp-driver)
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
#:meta-level 1
|
#:meta-level 1
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
(match e
|
(match e
|
||||||
[(message (at-meta (tcp-channel _ _ bs)))
|
[(message (at-meta (tcp-channel _ _ bs)))
|
||||||
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
(define input-string (string-trim (bytes->string/utf-8 bs)))
|
||||||
(if (equal? input-string "quit-network")
|
(if (equal? input-string "quit-dataspace")
|
||||||
(quit-network)
|
(quit-dataspace)
|
||||||
(message `(,user says ,input-string)))]
|
(message `(,user says ,input-string)))]
|
||||||
[(message `(,who says ,what))
|
[(message `(,who says ,what))
|
||||||
(say who "says: ~a" what)]
|
(say who "says: ~a" what)]
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(spawn-tcp-driver)
|
(spawn-tcp-driver)
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(spawn-demand-matcher (advertise (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
(observe (tcp-channel (?!) (?! (tcp-listener 5999)) ?))
|
||||||
#:meta-level 1
|
#:meta-level 1
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#f)]
|
#f)]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
|
|
||||||
(spawn-network (spawn r (void) (sub ?))
|
(spawn-dataspace (spawn r (void) (sub ?))
|
||||||
(spawn b 0 '()))
|
(spawn b 0 '()))
|
||||||
|
|
||||||
(define (echoer e s)
|
(define (echoer e s)
|
||||||
(match e
|
(match e
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
(patch-seq (sub 'die)
|
(patch-seq (sub 'die)
|
||||||
(sub (observe 'die))))
|
(sub (observe 'die))))
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
[(message (at-meta 'die)) (quit)]
|
[(message (at-meta 'die)) (quit)]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
;; Analogous to nc-incremental-meta-drop.rkt in the Redex model.
|
;; Analogous to nc-incremental-meta-drop.rkt in the Redex model.
|
||||||
;; Demonstrates (hopefully) correct processing of meta-interests when dropping a patch.
|
;; Demonstrates (hopefully) correct processing of meta-interests when dropping a patch.
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e u)
|
(spawn (lambda (e u)
|
||||||
(match u
|
(match u
|
||||||
[0 (transition 1 '())]
|
[0 (transition 1 '())]
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
(require syndicate/pretty)
|
(require syndicate/pretty)
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e counter)
|
(spawn (lambda (e counter)
|
||||||
(and e
|
(and e
|
||||||
(let ((new-counter (+ counter 1)))
|
(let ((new-counter (+ counter 1)))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
(require syndicate/pretty)
|
(require syndicate/pretty)
|
||||||
|
|
||||||
(spawn-network
|
(spawn-dataspace
|
||||||
(spawn (lambda (e counter)
|
(spawn (lambda (e counter)
|
||||||
(and e
|
(and e
|
||||||
(let ((new-counter (+ counter 1)))
|
(let ((new-counter (+ counter 1)))
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
1
|
1
|
||||||
(patch-seq (sub (observe (set-timer ? ? ?)))
|
(patch-seq (sub (observe (set-timer ? ? ?)))
|
||||||
(sub (timer-expired 'tick ?))))
|
(sub (timer-expired 'tick ?))))
|
||||||
(spawn-network (spawn r (void) (sub ?))
|
(spawn-dataspace (spawn r (void) (sub ?))
|
||||||
(spawn b 0 '()))
|
(spawn b 0 '()))
|
||||||
(spawn echoer
|
(spawn echoer
|
||||||
(void)
|
(void)
|
||||||
(sub (external-event (read-line-evt (current-input-port) 'any) ?)
|
(sub (external-event (read-line-evt (current-input-port) 'any) ?)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#lang syndicate
|
#lang syndicate
|
||||||
;; Demonstrates quit-network.
|
;; Demonstrates quit-dataspace.
|
||||||
|
|
||||||
(require (only-in racket/port read-bytes-line-evt))
|
(require (only-in racket/port read-bytes-line-evt))
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
[(message (at-meta (at-meta (external-event _ (list #"quit")))))
|
[(message (at-meta (at-meta (external-event _ (list #"quit")))))
|
||||||
(printf "Quitting just the leaf actor.\n")
|
(printf "Quitting just the leaf actor.\n")
|
||||||
(quit)]
|
(quit)]
|
||||||
[(message (at-meta (at-meta (external-event _ (list #"quit-network")))))
|
[(message (at-meta (at-meta (external-event _ (list #"quit-dataspace")))))
|
||||||
(printf "Terminating the whole network.\n")
|
(printf "Terminating the whole dataspace.\n")
|
||||||
(transition s (quit-network))]
|
(transition s (quit-dataspace))]
|
||||||
[_ #f]))
|
[_ #f]))
|
||||||
(void)
|
(void)
|
||||||
(sub (external-event (read-bytes-line-evt (current-input-port) 'any) ?)
|
(sub (external-event (read-bytes-line-evt (current-input-port) 'any) ?)
|
||||||
|
@ -31,6 +31,6 @@
|
||||||
(void)
|
(void)
|
||||||
(sub-to-alarm)))
|
(sub-to-alarm)))
|
||||||
|
|
||||||
(printf "Type 'quit' or 'quit-network'.\n")
|
(printf "Type 'quit' or 'quit-dataspace'.\n")
|
||||||
(spawn-network (spawn-command-listener)
|
(spawn-dataspace (spawn-command-listener)
|
||||||
(spawn-ticker))
|
(spawn-ticker))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
;; Demonstrate almost-wildcard assertions.
|
;; Demonstrate almost-wildcard assertions.
|
||||||
;; One actor subscribes to everything - and so initially sees itself.
|
;; One actor subscribes to everything - and so initially sees itself.
|
||||||
;; The other advertises everything except subscriptions and at-meta assertions.
|
;; The other advertises everything except subscriptions and at-meta assertions.
|
||||||
;; The first actor's aggregate view of the network then includes everything
|
;; The first actor's aggregate view of the dataspace then includes everything
|
||||||
;; except at-meta assertions.
|
;; except at-meta assertions.
|
||||||
|
|
||||||
(require syndicate/pretty)
|
(require syndicate/pretty)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
;; Breaking the infinite tower of nested Networks, connecting to the "real world" at the fracture line.
|
;; Breaking the infinite tower of nested Dataspaces, connecting to the "real world" at the fracture line.
|
||||||
|
|
||||||
(require racket/async-channel)
|
(require racket/async-channel)
|
||||||
(require racket/set)
|
(require racket/set)
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
;; Projection
|
;; Projection
|
||||||
;; Used to extract event descriptors and results from subscriptions
|
;; Used to extract event descriptors and results from subscriptions
|
||||||
;; from the ground VM's contained Network.
|
;; from the ground VM's contained Dataspace.
|
||||||
(define event-projection (observe (external-event (?!) ?)))
|
(define event-projection (observe (external-event (?!) ?)))
|
||||||
|
|
||||||
;; Interests -> (Listof RacketEvent)
|
;; Interests -> (Listof RacketEvent)
|
||||||
|
@ -74,10 +74,10 @@
|
||||||
(handle-evt (system-idle-evt) (lambda _ #f)))
|
(handle-evt (system-idle-evt) (lambda _ #f)))
|
||||||
|
|
||||||
;; Action* -> Void
|
;; Action* -> Void
|
||||||
;; Runs a ground VM, booting the outermost Network with the given Actions.
|
;; Runs a ground VM, booting the outermost Dataspace with the given Actions.
|
||||||
(define (run-ground . boot-actions)
|
(define (run-ground . boot-actions)
|
||||||
(let await-interrupt ((inert? #f)
|
(let await-interrupt ((inert? #f)
|
||||||
(w (make-network boot-actions))
|
(w (make-dataspace boot-actions))
|
||||||
(interests trie-empty))
|
(interests trie-empty))
|
||||||
;; (log-info "GROUND INTERESTS:\n~a" (trie->pretty-string interests))
|
;; (log-info "GROUND INTERESTS:\n~a" (trie->pretty-string interests))
|
||||||
(if (and inert? (trie-empty? interests))
|
(if (and inert? (trie-empty? interests))
|
||||||
|
@ -87,9 +87,9 @@
|
||||||
(current-ground-event-async-channel)
|
(current-ground-event-async-channel)
|
||||||
(if inert? never-evt idle-handler)
|
(if inert? never-evt idle-handler)
|
||||||
(extract-active-events interests))))
|
(extract-active-events interests))))
|
||||||
(trace-process-step e #f network-handle-event w)
|
(trace-process-step e #f dataspace-handle-event w)
|
||||||
(define resulting-transition (clean-transition (network-handle-event e w)))
|
(define resulting-transition (clean-transition (dataspace-handle-event e w)))
|
||||||
(trace-process-step-result e #f network-handle-event w #f resulting-transition)
|
(trace-process-step-result e #f dataspace-handle-event w #f resulting-transition)
|
||||||
(match resulting-transition
|
(match resulting-transition
|
||||||
[#f ;; inert
|
[#f ;; inert
|
||||||
(await-interrupt #t w interests)]
|
(await-interrupt #t w interests)]
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
Spawns an actor that executes each instantaneous action @racket[I] in
|
Spawns an actor that executes each instantaneous action @racket[I] in
|
||||||
sequence.}
|
sequence.}
|
||||||
|
|
||||||
@defform[(network I ...)]{
|
@defform[(dataspace I ...)]{
|
||||||
Spawns a network as a child of the network enclosing the executing actor. The
|
Spawns a dataspace as a child of the dataspace enclosing the executing actor. The
|
||||||
new network executes each instantaneous action @racket[I].}
|
new dataspace executes each instantaneous action @racket[I].}
|
||||||
|
|
||||||
@defproc[(send! [v any/c]
|
@defproc[(send! [v any/c]
|
||||||
[#:meta-level level natural-number/c 0])
|
[#:meta-level level natural-number/c 0])
|
||||||
void?]{
|
void?]{
|
||||||
Sends a message with body @racket[v]. The message is sent @racket[level]
|
Sends a message with body @racket[v]. The message is sent @racket[level]
|
||||||
networks removed from the network containing the actor performing the
|
dataspaces removed from the dataspace containing the actor performing the
|
||||||
@racket[send!].}
|
@racket[send!].}
|
||||||
|
|
||||||
@defproc[(assert! [v any/c]
|
@defproc[(assert! [v any/c]
|
||||||
|
@ -30,14 +30,14 @@ networks removed from the network containing the actor performing the
|
||||||
void?]{
|
void?]{
|
||||||
Asserts the value of @racket[v] until either explicitly retracted via
|
Asserts the value of @racket[v] until either explicitly retracted via
|
||||||
@racket[retract!] or the immediately enclosing actor exits. @racket[level]
|
@racket[retract!] or the immediately enclosing actor exits. @racket[level]
|
||||||
specifies which network the assertion should be made, in terms of relative
|
specifies which dataspace the assertion should be made, in terms of relative
|
||||||
distance from the network containing the enclosing actor.}
|
distance from the dataspace containing the enclosing actor.}
|
||||||
|
|
||||||
@defproc[(retract! [v any/c]
|
@defproc[(retract! [v any/c]
|
||||||
[#:meta-level level natural-number/c 0])
|
[#:meta-level level natural-number/c 0])
|
||||||
void?]{
|
void?]{
|
||||||
Retracts any assertions made by the immediately enclosing actor at
|
Retracts any assertions made by the immediately enclosing actor at
|
||||||
@racket[level] networks above the enclosing network of the form @racket[v].}
|
@racket[level] dataspaces above the enclosing dataspace of the form @racket[v].}
|
||||||
|
|
||||||
@section{Ongoing Behaviors (O)}
|
@section{Ongoing Behaviors (O)}
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,10 @@
|
||||||
(exn->string exn)))
|
(exn->string exn)))
|
||||||
(record-trace-event 'process-step-result (list (cons-pid pid) e beh st exn t)))
|
(record-trace-event 'process-step-result (list (cons-pid pid) e beh st exn t)))
|
||||||
|
|
||||||
;; (Option PID) Action Network -> Void
|
;; (Option PID) Action Dataspace -> Void
|
||||||
(define (trace-internal-action pid a w)
|
(define (trace-internal-action pid a w)
|
||||||
(record-trace-event 'internal-action (list (cons-pid pid) a w)))
|
(record-trace-event 'internal-action (list (cons-pid pid) a w)))
|
||||||
|
|
||||||
;; (Option PID) Action Network Transition -> Void
|
;; (Option PID) Action Dataspace Transition -> Void
|
||||||
(define (trace-internal-action-result pid a w t)
|
(define (trace-internal-action-result pid a w t)
|
||||||
(record-trace-event 'internal-action-result (list (cons-pid pid) a w t)))
|
(record-trace-event 'internal-action-result (list (cons-pid pid) a w t)))
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
(define show-message-actions? #f)
|
(define show-message-actions? #f)
|
||||||
(define show-actions? #f)
|
(define show-actions? #f)
|
||||||
(define show-routing-table? #f)
|
(define show-routing-table? #f)
|
||||||
(define network-is-boring? #t)
|
(define dataspace-is-boring? #t)
|
||||||
|
|
||||||
(define (set-stderr-trace-flags! flags-string)
|
(define (set-stderr-trace-flags! flags-string)
|
||||||
(set! flags (for/set [(c flags-string)] (string->symbol (string c))))
|
(set! flags (for/set [(c flags-string)] (string->symbol (string c))))
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
(set-flag! M show-message-actions?)
|
(set-flag! M show-message-actions?)
|
||||||
(set-flag! a show-actions?)
|
(set-flag! a show-actions?)
|
||||||
(set-flag! g show-routing-table?)
|
(set-flag! g show-routing-table?)
|
||||||
(set! network-is-boring? (not (set-member? flags 'N))))
|
(set! dataspace-is-boring? (not (set-member? flags 'N))))
|
||||||
|
|
||||||
(set-stderr-trace-flags! (or (getenv "MINIMART_TRACE") ""))
|
(set-stderr-trace-flags! (or (getenv "MINIMART_TRACE") ""))
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
(apply fprintf (current-error-port) fmt args))
|
(apply fprintf (current-error-port) fmt args))
|
||||||
|
|
||||||
(define (boring-state? state)
|
(define (boring-state? state)
|
||||||
(or (and (network? state) network-is-boring?)
|
(or (and (dataspace? state) dataspace-is-boring?)
|
||||||
(void? state)))
|
(void? state)))
|
||||||
|
|
||||||
(define (set-color! c) (when colored-output? (output "\e[0~am" c)))
|
(define (set-color! c) (when colored-output? (output "\e[0~am" c)))
|
||||||
|
@ -163,14 +163,14 @@
|
||||||
(syndicate-pretty-print (transition-state t) (current-error-port)))))))]
|
(syndicate-pretty-print (transition-state t) (current-error-port)))))))]
|
||||||
[('internal-action (list pids a old-w))
|
[('internal-action (list pids a old-w))
|
||||||
(define pidstr (format-pids pids))
|
(define pidstr (format-pids pids))
|
||||||
(define oldcount (hash-count (network-behaviors old-w)))
|
(define oldcount (hash-count (dataspace-behaviors old-w)))
|
||||||
(match a
|
(match a
|
||||||
[(? spawn?)
|
[(? spawn?)
|
||||||
;; Handle this in internal-action-result
|
;; Handle this in internal-action-result
|
||||||
(void)]
|
(void)]
|
||||||
['quit
|
['quit
|
||||||
(when (or show-process-lifecycle? show-actions?)
|
(when (or show-process-lifecycle? show-actions?)
|
||||||
(define interests (mux-interests-of (network-mux old-w) (car pids)))
|
(define interests (mux-interests-of (dataspace-mux old-w) (car pids)))
|
||||||
(with-color BRIGHT-RED
|
(with-color BRIGHT-RED
|
||||||
(output "~a exiting (~a total processes remain)\n"
|
(output "~a exiting (~a total processes remain)\n"
|
||||||
pidstr
|
pidstr
|
||||||
|
@ -178,9 +178,9 @@
|
||||||
(unless (trie-empty? interests)
|
(unless (trie-empty? interests)
|
||||||
(output "~a's final interests:\n" pidstr)
|
(output "~a's final interests:\n" pidstr)
|
||||||
(pretty-print-trie interests (current-error-port))))]
|
(pretty-print-trie interests (current-error-port))))]
|
||||||
[(quit-network)
|
[(quit-dataspace)
|
||||||
(with-color BRIGHT-RED
|
(with-color BRIGHT-RED
|
||||||
(output "Process ~a performed a quit-network.\n" pidstr))]
|
(output "Process ~a performed a quit-dataspace.\n" pidstr))]
|
||||||
[(? patch? p)
|
[(? patch? p)
|
||||||
(when (or show-actions? show-patch-actions?)
|
(when (or show-actions? show-patch-actions?)
|
||||||
(output "~a performing a patch:\n" pidstr)
|
(output "~a performing a patch:\n" pidstr)
|
||||||
|
@ -193,15 +193,15 @@
|
||||||
(when (transition? t)
|
(when (transition? t)
|
||||||
(define new-w (transition-state t))
|
(define new-w (transition-state t))
|
||||||
(define pidstr (format-pids pids))
|
(define pidstr (format-pids pids))
|
||||||
(define newcount (hash-count (network-behaviors new-w)))
|
(define newcount (hash-count (dataspace-behaviors new-w)))
|
||||||
(match a
|
(match a
|
||||||
[(? spawn?)
|
[(? spawn?)
|
||||||
(when (or show-process-lifecycle? show-actions?)
|
(when (or show-process-lifecycle? show-actions?)
|
||||||
(define newpid (mux-next-pid (network-mux old-w)))
|
(define newpid (mux-next-pid (dataspace-mux old-w)))
|
||||||
(define newpidstr (format-pids (cons newpid (cdr pids)))) ;; replace parent pid
|
(define newpidstr (format-pids (cons newpid (cdr pids)))) ;; replace parent pid
|
||||||
(define interests (mux-interests-of (network-mux new-w) newpid))
|
(define interests (mux-interests-of (dataspace-mux new-w) newpid))
|
||||||
(define behavior (hash-ref (network-behaviors new-w) newpid '#:missing-behavior))
|
(define behavior (hash-ref (dataspace-behaviors new-w) newpid '#:missing-behavior))
|
||||||
(define state (hash-ref (network-states new-w) newpid '#:missing-state))
|
(define state (hash-ref (dataspace-states new-w) newpid '#:missing-state))
|
||||||
(with-color BRIGHT-GREEN
|
(with-color BRIGHT-GREEN
|
||||||
(output "~a ~v spawned from ~a (~a total processes now)\n"
|
(output "~a ~v spawned from ~a (~a total processes now)\n"
|
||||||
newpidstr
|
newpidstr
|
||||||
|
@ -218,8 +218,8 @@
|
||||||
;; other cases handled in internal-action
|
;; other cases handled in internal-action
|
||||||
(void)])
|
(void)])
|
||||||
(when show-routing-table?
|
(when show-routing-table?
|
||||||
(define old-table (mux-routing-table (network-mux old-w)))
|
(define old-table (mux-routing-table (dataspace-mux old-w)))
|
||||||
(define new-table (mux-routing-table (network-mux new-w)))
|
(define new-table (mux-routing-table (dataspace-mux new-w)))
|
||||||
(when (not (equal? old-table new-table))
|
(when (not (equal? old-table new-table))
|
||||||
(with-color BRIGHT-BLUE
|
(with-color BRIGHT-BLUE
|
||||||
(output "~a's routing table:\n" (format-pids (cdr pids)))
|
(output "~a's routing table:\n" (format-pids (cdr pids)))
|
||||||
|
|
Loading…
Reference in New Issue