Note that there are some explanatory texts on larger screens.

plurals
  1. POis there a way to still get which queue I am on instead of dispatch_get_current_queue?
    text
    copied!<p>My problem is very simple</p> <pre><code>+ (void) SpecialDispatchSyncTo:(dispatch_queue_t)iQueue DispatchBlock:(dispatch_block_t)block { if (dispatch_get_current_queue() == iQueue) { block(); } else { dispatch_sync(iQueue, block); } } </code></pre> <p>I use this bit of code to increase performance of some of my apps.</p> <p>It's use is fairly obvious from the code - when I am dispatching to a specific queue it directly invokes the block instead of going through the dispatcher. </p> <p>now my problem is with the ios 6 deprecation of the get_current_queue function, any ideas how to retain this functionality with ios 6 + ?</p> <p>edit:</p> <p>This isn't a duplicate of <a href="https://stackoverflow.com/questions/13237417/alternatives-to-dispatch-get-current-queue-for-completion-blocks-in-ios-6">Alternatives to dispatch_get_current_queue() for completion blocks in iOS 6</a></p> <p>To better explain myself, and unlike the linked duplicate looking question... I have no desire to run the block on the "caller method's queue"... rather I want to optimise the dispatch(I'm overriding the normal dispatch methods in essence) by not dispatching to a queue IF I'm already on that queue.</p> <p>For example, consider the scenario where function a (which is a UI event callback) and function b (background low priority queue) both call function c, which among other things needs to dispatch a block to the "background low priority queue"... a pointless dispatch if I'm in the flow of function b -> function c... hence my optimisation. This improves performance I guarantee it, and I'll implement my own "get current queue" if needed by enhancing the runloop object but I'm not sure I want to go down that path and wanted to see if someone has ideas how to do it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload