In the case of performing very small tasks, performing GCD takes a pretty large cost rather than actual operation inside the critical scope.
So I propose this PR that uses NSLock to get mutual-exclusion.
queue.async() is wasteful if the dispatched block is small (< 1ms), as it will most likely require a new thread due to libdispatch's overcommit behavior. Prefer locking to protect shared state (rather than switching the execution context).
And I found some cases which are not protected from concurrent operations.
⚠️ This modification is still very part of this library. It affects consistency against the code entirely.
Thanks for this open-sourced library!
In the case of performing very small tasks, performing GCD takes a pretty large cost rather than actual operation inside the critical scope. So I propose this PR that uses
NSLock
to get mutual-exclusion.Referencing this note: https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
And I found some cases which are not protected from concurrent operations.
⚠️ This modification is still very part of this library. It affects consistency against the code entirely.