@benjaminencz wonderful post! I have a concern with the suggestion though - what if the lib relies on thread-specific data, like SQLite?
-
-
-
@mattie Good point. If you know that lib relies on thread semantics you should check threads. If you know it relies on GCD check queues. -
@mattie But if lib claims "only use me from the main thread", checking for main queue will check both boxes in case lib relies on GCD. -
@benjaminencz oh it will? How is that possible with a dispatch_sync? -
@mattie I meant that if you check for main queue with `dispatch_get_specific` you've also checked for main thread. -
@mattie Since main queue will ever only execute on main thread. - View other replies
-
@benjaminencz dispatch_async will always be on the main thread, did you mean that? - View other replies
-
@mattie Worth mentioning it only seems true in AppKit/UIKit apps, see:https://gist.github.com/jspahrsummers/af6ddfbabf3894bde981 … - View other replies
- Show more
-
-
-
@benjaminencz your solution can deadlock under this case Main Thread -> Main Queue -> other_queue -> your code ->: sync call -
@dtorres Thanks! I’m aware of that. Really wouldn’t dispatch_sync from main queue in actual code. Needed some example. -
@benjaminencz you may not, the stackoverflowers and other inexperienced readers definitely will. Put a big ass warning in there -
@dtorres Good point! Thanks
-
-
@benjaminencz@olebegemann@krzyzanowskim Your timing is impeccable. This +@cocoawithlove. Exactly what I needed
http://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Benjamin Encz
Matt Massicotte
Diego Torres
karlBowden.async()