mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Store postponed actions in a queue
This commit is contained in:
parent
80814ef167
commit
7f33f64d25
|
@ -460,10 +460,10 @@ function $rt_rootInvocationAdapter(f) {
|
|||
});
|
||||
f.apply(this, args);
|
||||
var thread = $rt_getThread();
|
||||
while (thread.postponed) {
|
||||
var postponed = thread.postponed;
|
||||
thread.postponed = null;
|
||||
postponed();
|
||||
if (thread.hasOwnProperty("postponed")) {
|
||||
while (thread.postponed.length > 0) {
|
||||
thread.postponed.shift()();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -497,13 +497,12 @@ function $rt_continue(f) {
|
|||
var self = this;
|
||||
var args = arguments;
|
||||
var thread = $rt_getThread();
|
||||
var oldPostponed = thread.postponed;
|
||||
thread.postponed = function() {
|
||||
if (oldPostponed) {
|
||||
oldPostponed();
|
||||
if (!thread.hasOwnProperty("postponed")) {
|
||||
thread.postponed = [];
|
||||
}
|
||||
thread.postponed.push(function() {
|
||||
f.apply(self, args);
|
||||
};
|
||||
});
|
||||
};
|
||||
} else {
|
||||
return f;
|
||||
|
|
Loading…
Reference in New Issue
Block a user