Merge pull request from mzgoddard/broadcast-and-wait-promise

yield a tick if broadcastandwait is waiting on threads waiting for a future tick
This commit is contained in:
Ray Schamp 2018-06-13 15:58:37 -04:00 committed by GitHub
commit f5234c777a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 8 deletions
src/engine

View file

@ -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.