mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-06 19:41:51 -04:00
add Runtime.isWaitingThread
Add a Runtime Thread helper to check if a thread is in a state where it will not change at least until next frame. This includes any state where the thread is done, as that will not change either.
This commit is contained in:
parent
9311a274d5
commit
0a006dc981
1 changed files with 13 additions and 0 deletions
|
@ -1017,6 +1017,19 @@ class Runtime extends EventEmitter {
|
|||
this.threads.indexOf(thread) > -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a thread is waiting for more information or done.
|
||||
* @param {?Thread} thread Thread object to check.
|
||||
* @return {boolean} True if the thread is waiting
|
||||
*/
|
||||
isWaitingThread (thread) {
|
||||
return (
|
||||
thread.status === Thread.STATUS_PROMISE_WAIT ||
|
||||
thread.status === Thread.STATUS_YIELD_TICK ||
|
||||
!this.isActiveThread(thread)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a script.
|
||||
* @param {!string} topBlockId ID of block that starts the script.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue