mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-18 09:21:04 -04:00
broadcast and wait must wait for threads to be removed from runtime
This commit is contained in:
parent
a0b7e94c9e
commit
65ee6b7cac
2 changed files with 12 additions and 2 deletions
src/blocks
|
@ -109,7 +109,12 @@ class Scratch3EventBlocks {
|
|||
}
|
||||
// We've run before; check if the wait is still going on.
|
||||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
// Scratch 2 considers threads to be waiting if they are still in
|
||||
// runtime.threads. Threads that have run all their blocks, or are
|
||||
// marked done but still in runtime.threads are still considered to
|
||||
// be waiting.
|
||||
const waiting = util.stackFrame.startedThreads
|
||||
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
|
||||
if (waiting) {
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
|
|
|
@ -415,7 +415,12 @@ class Scratch3LooksBlocks {
|
|||
}
|
||||
// We've run before; check if the wait is still going on.
|
||||
const instance = this;
|
||||
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
|
||||
// Scratch 2 considers threads to be waiting if they are still in
|
||||
// runtime.threads. Threads that have run all their blocks, or are
|
||||
// marked done but still in runtime.threads are still considered to
|
||||
// be waiting.
|
||||
const waiting = util.stackFrame.startedThreads
|
||||
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
|
||||
if (waiting) {
|
||||
// If all threads are waiting for the next tick or later yield
|
||||
// for a tick as well. Otherwise yield until the next loop of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue