mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
yield a thread loop or tick in event_broadcastandwait
- yield a thread loop or tick in looks_switchbackdroptoandwait If all threads broadcastAndWait is watching are "waiting" for a future frame, yield until the next tick so event_broadcastandwait also defers to a future frame.
This commit is contained in:
parent
0a006dc981
commit
d161251a9b
2 changed files with 22 additions and 2 deletions
|
@ -100,7 +100,17 @@ class Scratch3EventBlocks {
|
|||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
if (waiting) {
|
||||
util.yield();
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
// the threads.
|
||||
if (
|
||||
util.stackFrame.startedThreads
|
||||
.every(thread => instance.runtime.isWaitingThread(thread))
|
||||
) {
|
||||
util.yieldTick();
|
||||
} else {
|
||||
util.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,7 +409,17 @@ class Scratch3LooksBlocks {
|
|||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
if (waiting) {
|
||||
util.yield();
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
// the threads.
|
||||
if (
|
||||
util.stackFrame.startedThreads
|
||||
.every(thread => instance.runtime.isWaitingThread(thread))
|
||||
) {
|
||||
util.yieldTick();
|
||||
} else {
|
||||
util.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue