#Goal
Detect if dispatch_sync
will deadlock and avoid it (because the current queue stack is ultimately on self.onQueue
)
#Possibly Sketchy
This does appear to work; can you think of any reasons why it would fail or be dangerous?
- Technically setting a queue specific key on the global main queue is questionable but it does work
- A complex tree or re-entrancy can still cause a deadlock (eg if main queue is busy while bg queue wants to dispatch main, then main queue tries to
doAThing
)