Fixed issues with not cancelling block operations properly #302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was noticing some issues where the library sometimes spawns a lot of extra threads (around 100 threads). I tracked down the issue to the way the library uses BlockOperation. While the library calls code calls
cancelAllOperations
, the code within the block operations doesn't check the isCancelled flag during execution. This is incorrect, based on Apple's documentation on OperationQueue:As a result, the block operations weren't cancelling properly. To fix the issue, I revised the use of BlockOperation so that the code checks the isCancelled flag at appropriate times, such as in
while
loops.I should also note that I was having trouble with running the tests, as stated in issue #297. Let me know if there's any test failures.
@daltoniam Please review.