Fix that completion block and set image block are called asynchronously for UIView+WebCache #2093
  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.
  
    
  
    
Add a more common macro to do current queue check
New Pull Request Checklist
I have read and understood the CONTRIBUTING guide
I have read the Documentation
I have searched for a similar pull request in the project and found none
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
I have added the required tests to prove the fix/feature I am adding
I have updated the documentation (if necessary)
I have run the tests and they pass
I have run the lint and it passes (
pod lib lint)This merge request fixes / reffers to the following issues: #2092
Pull Request Description
Our use relay on the behavior that completion and set-image block should happend during one run loop without add it to the end of main queue. This means we should use
dispatch_main_async_safeto dispatch queue when current queue is main queue.This behavior is changed during #2047. At that time I didn't realized that completion and set-image block should immediately call when current queue is main queue. So we then do code refactor about this logic.
In fact, we should do like this:
This can work, but not looks well. I think we can create a more common usage macro, like this, to solve this kind of use case:
Then we just need to change it to this:
dispatch_queue_async_safe(targetQueue, ^{});I don't think this is a break API change. But if someone think this change should not happened on 4.2.2 patch release. I can change back to that first one in description to avoid modify any header file.
Any idea ?