Fix the next thread is skipped after clone deleted

Problem:
When a clone is deleted, its thread is removed from the thread
list; but the index "i" in the execution for-loop will still +1,
making the next thread skipped.

Changes:
Added a flag "isKilled" on a thread;
Set the flag when a thread is removed from the thread list;
reduce the "i" counter if the thread of the current loop is removed.
This commit is contained in:
Wang Yu 2017-05-12 14:01:37 +08:00
parent 312e15932e
commit 6ec231db9d
3 changed files with 10 additions and 0 deletions
src/engine

View file

@ -69,6 +69,9 @@ class Sequencer {
// Normal-mode thread: step.
this.stepThread(activeThread);
activeThread.warpTimer = null;
if (activeThread.isKilled) {
i--; // if the thread is removed from the list (killed), do not increase index
}
}
if (activeThread.status === Thread.STATUS_RUNNING) {
numActiveThreads++;