Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5. Concurrency > 5.4. Dispatching Tasks to Grand Central Dispatch

5.4. Dispatching Tasks to Grand Central Dispatch

Problem

You want to learn how to create a block of code that can be executed by GCD.

Solution

There are two ways to submit tasks to dispatch queues:

Discussion

Block objects are the best way of utilizing GCD and its enormous power. Some GCD functions have been extended to allow programmers to use C functions instead of block objects. However, the truth is that only a limited set of GCD functions allow programmers to use C functions, so please do read the recipe about block objects (Recipe 5.1) before proceeding any further.

C functions that have to be supplied to various GCD functions should be of type dispatch_function_t, which is defined as follows in the Apple libraries:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial