Dispatch API

Queues

Before you can schedule work on a queue, you need to get ahold of a queue to do the work on. You can get the main queue with

dispatch_queue_t dispatch_get_main_queue (void);

You can schedule activity on the main thread by using this queue. This is a serial queue, so work will issue and complete in FIFO order.

dispatch_queue_t dispatch_get_global_queue (long priority,
                                            unsigned long flags);

This gives you one of the global concurrent queues, whose priority is one of the DISPATCH_QUEUE_PRIORITY_LOW, DEFAULT, or HIGH priority constants. Pass 0UL for flags; it is ignored now and is an expansion point for the future. The priority refers to which queue gets its blocks scheduled. The default queue’s blocks only get run on threads ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.