Store postponed actions in a queue

This commit is contained in:
konsoletyper 2015-03-09 22:20:59 +03:00
parent 80814ef167
commit 7f33f64d25

View File

@ -460,10 +460,10 @@ function $rt_rootInvocationAdapter(f) {
}); });
f.apply(this, args); f.apply(this, args);
var thread = $rt_getThread(); var thread = $rt_getThread();
while (thread.postponed) { if (thread.hasOwnProperty("postponed")) {
var postponed = thread.postponed; while (thread.postponed.length > 0) {
thread.postponed = null; thread.postponed.shift()();
postponed(); }
} }
} }
} }
@ -491,23 +491,22 @@ function $rt_s(index) {
} }
var $rt_continueCounter = 0; var $rt_continueCounter = 0;
function $rt_continue(f) { function $rt_continue(f) {
if ($rt_continueCounter++ == 5) { if ($rt_continueCounter++ == 5) {
$rt_continueCounter = 0; $rt_continueCounter = 0;
return function() { return function() {
var self = this; var self = this;
var args = arguments; var args = arguments;
var thread = $rt_getThread(); var thread = $rt_getThread();
var oldPostponed = thread.postponed; if (!thread.hasOwnProperty("postponed")) {
thread.postponed = function() { thread.postponed = [];
if (oldPostponed) { }
oldPostponed(); thread.postponed.push(function() {
} f.apply(self, args);
f.apply(self, args); });
}; };
}; } else {
} else { return f;
return f; }
}
} }
function $rt_guardAsync(f, continuation) { function $rt_guardAsync(f, continuation) {
return function() { return function() {