Merge pull request from mzgoddard/stop-other-asks

Stop other asks
This commit is contained in:
Andrew Sliwinski 2018-10-15 13:16:49 -04:00 committed by GitHub
commit 23f6346045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 0 deletions
src/engine

View file

@ -383,6 +383,15 @@ class Runtime extends EventEmitter {
return 'PROJECT_STOP_ALL';
}
/**
* Event name for target being stopped by a stop for target call.
* Used by blocks that need to stop individual targets.
* @const {string}
*/
static get STOP_FOR_TARGET () {
return 'STOP_FOR_TARGET';
}
/**
* Event name for visual value report.
* @const {string}
@ -1450,6 +1459,9 @@ class Runtime extends EventEmitter {
* @param {Thread=} optThreadException Optional thread to skip.
*/
stopForTarget (target, optThreadException) {
// Emit stop event to allow blocks to clean up any state.
this.emit(Runtime.STOP_FOR_TARGET, target, optThreadException);
// Stop any threads on the target.
for (let i = 0; i < this.threads.length; i++) {
if (this.threads[i] === optThreadException) {