ember-concurrency
ember-concurrency copied to clipboard
task.cancelAll(); does not decremented numRunning
I call cancelAll() on task group, but numRunning not decremented accordingly it does not recompute isRunning flag.
testTaskGroup: taskGroup().drop(),
task: task(function*() {
// for example
while (true) {
yield timeout(10000);
}
}).group('testTaskGroup'),
run this task
this.testTaskGroup.isRunning == true
and call this.testTaskGroup.cancelAll()
or this.task.cancelAll()
but
this.testTaskGroup.isRunning == true
numRunning == 1
This issue will be used at an EmberConf Contributor Workshop, so please no one else try and fix in the meantime:
For any EmberConf contributors who wants to try and fix this, I'd recommend the following:
- Create a breaking test case that demonstrates the issue at the bottom of task-states-test.js. Amazingly I don't think there were ever tests for numRunning, so no surprise it's got bugs.
- Start by taking a look at the Scheduler class's cancelAll method. Every e-c task internally has its own scheduler which updates the derived state of a Task when its TaskInstances start and stop (and FYI, in the case of TaskGroups, multiple tasks can share the same scheduler provided by the task group).
- Somewhere in the scheduler class there is probably some corner case where numRunning is not updated. Try and see how/why/where this is happening. Once you find it, double check the other properties that might be getting set (or failing to get set) in the same way, and see if there are any similar bugs with them.
- Submit a PR :)