Make shutdownWorld have immediate effect, rather than processing useless internal actions

This commit is contained in:
Tony Garnock-Jones 2014-03-10 12:15:16 -04:00
parent 0eb5d2b02b
commit 73d9041245
1 changed files with 4 additions and 2 deletions

View File

@ -191,6 +191,7 @@ function filterEvent(e, routes) {
function World(bootFn) { function World(bootFn) {
this.nextPid = 0; this.nextPid = 0;
this.alive = true;
this.eventQueue = []; this.eventQueue = [];
this.processTable = {}; this.processTable = {};
this.downwardRoutes = []; this.downwardRoutes = [];
@ -274,7 +275,7 @@ World.prototype.isQuiescent = function () {
World.prototype.step = function () { World.prototype.step = function () {
this.dispatchEvents(); this.dispatchEvents();
this.performActions(); this.performActions();
return this.stepChildren() || !this.isQuiescent(); return this.alive && (this.stepChildren() || !this.isQuiescent());
}; };
World.prototype.startStepping = function () { World.prototype.startStepping = function () {
@ -346,7 +347,7 @@ World.prototype.performActions = function () {
var queue = this.processActions; var queue = this.processActions;
this.processActions = []; this.processActions = [];
var item; var item;
while ((item = queue.shift())) { while ((item = queue.shift()) && this.alive) {
this.performAction(item[0], item[1]); this.performAction(item[0], item[1]);
} }
}; };
@ -384,6 +385,7 @@ World.prototype.performAction = function (pid, action) {
} }
break; break;
case "shutdownWorld": case "shutdownWorld":
this.alive = false; // force us to stop doing things immediately
World.exit(); World.exit();
break; break;
default: default: