Repair syndicate/js just like commit 1fa5167 repaired syndicate/rkt.

This commit is contained in:
Tony Garnock-Jones 2018-03-27 22:21:14 +13:00
parent 1fa5167e20
commit 06224b52a8
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,55 @@
// bin/syndicatec compiler/demo-synthetic-patch-2.js | node
//
// Analogous example to syndicate/racket/syndicate/examples/actor/example-synthetic-patch-2.rkt.
//
// Symptomatic output:
//
// Outer value 4 = 4
// Value 0 = 0
// Value 1 = 1
// Value 2 = 2
// Value 3 = 3
//
// Correct output:
//
// Outer value 4 = 4
// Value 0 = 0
// Value 1 = 1
// Value 2 = 2
// Value 3 = 3
// Value 4 = 4
// Value 5 = 5
var Syndicate = require('./src/main.js');
assertion type mapping(key, value);
assertion type ready();
ground dataspace {
spawn {
field this.ofInterest = 0;
during ready() {
on asserted mapping(this.ofInterest, $v) {
console.log("Value", this.ofInterest, "=", v);
this.ofInterest += 1;
}
}
on asserted mapping(4, $v) {
console.log("Outer value", 4, "=", v);
}
}
spawn {
assert mapping(0, 0);
assert mapping(1, 1);
assert mapping(2, 2);
assert mapping(3, 3);
assert mapping(4, 4);
assert mapping(5, 5);
on start {
react {
assert ready();
}
}
}
}

View File

@ -88,8 +88,14 @@ Actor.prototype.quiesce = function() {
if (!facet.terminated) { if (!facet.terminated) {
withCurrentFacet(facet, function () { withCurrentFacet(facet, function () {
var patch = Patch.retract(__).andThen(endpoint.subscriptionFn.call(facet.fields)); var patch = Patch.retract(__).andThen(endpoint.subscriptionFn.call(facet.fields));
var newInterests = patch.prunedBy(facet.actor.mux.interestsOf(endpoint.eid));
var newlyRelevantKnowledge =
Patch.biasedIntersection(facet.actor.knowledge, newInterests.added);
var r = facet.actor.mux.updateStream(endpoint.eid, patch); var r = facet.actor.mux.updateStream(endpoint.eid, patch);
Dataspace.stateChange(r.deltaAggregate); Dataspace.stateChange(r.deltaAggregate);
facet.handleEvent(_Dataspace.stateChange(new Patch.Patch(newlyRelevantKnowledge,
Trie.emptyTrie)),
true);
}); });
} }
}); });