From 73d9041245217995015d05b08fa8091358490965 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 10 Mar 2014 12:15:16 -0400 Subject: [PATCH] Make shutdownWorld have immediate effect, rather than processing useless internal actions --- marketplace.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/marketplace.js b/marketplace.js index 554ba37..4672f17 100644 --- a/marketplace.js +++ b/marketplace.js @@ -191,6 +191,7 @@ function filterEvent(e, routes) { function World(bootFn) { this.nextPid = 0; + this.alive = true; this.eventQueue = []; this.processTable = {}; this.downwardRoutes = []; @@ -274,7 +275,7 @@ World.prototype.isQuiescent = function () { World.prototype.step = function () { this.dispatchEvents(); this.performActions(); - return this.stepChildren() || !this.isQuiescent(); + return this.alive && (this.stepChildren() || !this.isQuiescent()); }; World.prototype.startStepping = function () { @@ -346,7 +347,7 @@ World.prototype.performActions = function () { var queue = this.processActions; this.processActions = []; var item; - while ((item = queue.shift())) { + while ((item = queue.shift()) && this.alive) { this.performAction(item[0], item[1]); } }; @@ -384,6 +385,7 @@ World.prototype.performAction = function (pid, action) { } break; case "shutdownWorld": + this.alive = false; // force us to stop doing things immediately World.exit(); break; default: