dispatch_get_current_queue never made any sense in the first place. Here's why: There are several “root” queues (one for each priority, and then for the main queue). Each successive queue ultimately targets one of these root queues. This means that in general there is no answer to the question "What queue am I starting?"
For example, if you have queue B that is aimed at queue A, then A or B will be a reasonable answer to this question for a block sent to queue B. In addition, since all queues ultimately target one of the global / root perhaps the best answer would be "any root queue that caused it to finish executing", except that it is not very useful to anyone because it does not significantly distinguish anything.
In my experience, in most cases, what people want from dispatch_get_current_queue is the answer to the question: "What kind of queue was I originally introduced to?" However, by definition, whatever code represented by the block no longer knows which queue it was sent to (since it executes the presentation). Therefore, perhaps, if you needed to capture this information, you could do it with the least amount of time; you do not need dispatch_get_current_queue to answer this question. For these cases, dispatch_get_current_queue will be just a shortcut and a disadvantage in this (due to queue targeting).
Another big class of cases is when you want to know if you are in the main line. -[NSThread isMainThread] is sufficient / authoritative for this, so you do not need dispatch_get_current_queue for this.
Another respondent also noted that dispatch_get_current_queue often abused when trying to emulate a recursive lock with GCD queues. It is not possible to reliably implement recursive locks on a queue-based system because "queues are not locks." I wrote several times about this particular situation in another answer .
ipmcc
source share