Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best to use global or custom named GCD queues?

My understanding is that // 001 gets a high priority concurrent queue

// 001
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);

and that // 002 creates a new custom serial queue

// 002
dispatch_queue_t queue = dispatch_queue_create("bgQueue", NULL);

My question, is there a chance that other processes (on the iPhone, other apps etc.) will be queued on the global queues so you may have to wait (albeit briefly) to execute. If this is the case would it be best to always create custom queues where you know you have sole access?

like image 378
fuzzygoat Avatar asked Sep 04 '12 16:09

fuzzygoat


1 Answers

  • The 001 gets the high-priority queue, not creates it. The three global queues are automatically created for your application; they are always available.
  • The three global queues are global only within your application, in the same sense as global variables are global. These queues are still private to each application in which they are created.
  • The main difference between private and global queue is used to be that private queues are were sequential, while global queues are concurrent. The differences between the two are summarized in Table 3-1 of GCD documentation. EDIT : In OS X v10.7 and later, the private queues can now also be concurrent by passing DISPATCH_QUEUE_CONCURRENT (thanks, Rob, for the correction).
like image 153
Sergey Kalinichenko Avatar answered Sep 28 '22 10:09

Sergey Kalinichenko