New shutdownWorld action

This commit is contained in:
Tony Garnock-Jones 2014-02-28 09:46:59 -05:00
parent 0054254aed
commit c57833938a
1 changed files with 11 additions and 0 deletions

View File

@ -118,6 +118,10 @@ function sendMessage(m, metaLevel, isFeedback) {
isFeedback: (isFeedback === undefined) ? false : isFeedback };
}
function shutdownWorld() {
return { type: "shutdownWorld" };
}
/*---------------------------------------------------------------------------*/
/* Metafunctions */
@ -218,6 +222,10 @@ World.exit = function (exn) {
World.current().killActive(exn);
};
World.shutdownWorld = function () {
World.current().enqueueAction(shutdownWorld());
};
World.withWorldStack = function (stack, f) {
var oldStack = World.stack;
World.stack = stack;
@ -373,6 +381,9 @@ World.prototype.performAction = function (pid, action) {
World.send(action.message, action.metaLevel - 1, action.isFeedback);
}
break;
case "shutdownWorld":
World.exit();
break;
default:
throw { message: "Action type " + action.type + " not understood",
action: action };