This repository was archived by the owner on Nov 15, 2024. It is now read-only.
Feature/add extension to support tests#96
Open
LisaKonysheva wants to merge 5 commits intopluralsight:masterfrom
Open
Feature/add extension to support tests#96LisaKonysheva wants to merge 5 commits intopluralsight:masterfrom
LisaKonysheva wants to merge 5 commits intopluralsight:masterfrom
Conversation
…pletion block execution
Problem was that “isReady” property change KVO event was generated on every “state” property change, but in most of cases state-change doesn’t mean isReady-change. After every isReady KVO event, isReady property is read by NSOperations runtime. Since state-change (and as a result isReady KVO event) may happen and happens in multiple threads, isReady-getter is called from multiple threads too. The problem happens when isReady is called from multiple threads around the same time: the first call return False, but the second one returns True. Since there are two threads, first call can be actually finished after second one. In this case NSOperations runtime receivce isReady state value in the order like [false, false… false, true, false]. In this situation operations is actually ready, but it is not executed by queue (looks like because last isReady state was False). To fix the described problem idea is to stop bombing with KVO events. Actually during NSOperation life isReady is changed only once from false -> true. So ideally is to have only one KVO event when operations is really ready.
jjatie
reviewed
Nov 14, 2018
| operation.addCompletionBlock { [weak self, weak operation] in | ||
| guard let queue = self, let operation = operation else { return } | ||
| queue.delegate?.operationQueue?(queue, operationDidFinish: operation, withErrors: []) | ||
| if let delegate = queue.delegate { |
There was a problem hiding this comment.
Why write something more verbose? Optional chaining already indicated that we are only performing the delegate if the delegate exists.
|
No description? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.