Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword or section
Like this

Table Of Contents

Organization of This Document
A Note About Terminology
See Also
The Move Away from Threads
Concurrency and Application Design
Dispatch Queues
Dispatch Sources
Operation Queues
Asynchronous Design Techniques
Define Your Application’s Expected Behavior
Factor Out Executable Units of Work
Identify the Queues You Need
Tips for Improving Efficiency
Performance Implications
Concurrency and Other Technologies
OpenCL and Concurrency
When to Use Threads
About Operation Objects
Table2-1 Operation classes of the Foundation framework
Concurrent Versus Nonconcurrent Operations
Creating an NSInvocationOperation Object
Listing2-1 Creating anNSInvocationOperation object
Creating an NSBlockOperation Object
Listing2-2 Creating anNSBlockOperation object
Defining a Custom Operation Object
Performing the Main Task
Listing2-3 Defining a simple operation object
Responding to Cancellation Events
Listing2-4 Responding to a cancellation request
Configuring Operations for Concurrent Execution
Table2-2 Methods to override for concurrent operations
Listing2-5 Defining a concurrent operation
Listing2-7 Updating an operation at completion time
Maintaining KVO Compliance
Customizing the Execution Behavior of an Operation Object
Configuring Interoperation Dependencies
Changing an Operation’s Execution Priority
Changing the Underlying Thread Priority
Setting Up a Completion Block
Tips for Implementing Operation Objects
Managing Memory in Operation Objects
Listing2-8 Creating an autorelease pool for an operation
Handling Errors and Exceptions
Determining an Appropriate Scope for Operation Objects
Executing Operations
Adding Operations to an Operation Queue
Executing Operations Manually
Listing2-9 Executing an operation object manually
Canceling Operations
Waiting for Operations to Finish
Suspending and Resuming Queues
About Dispatch Queues
Table3-1 Types of dispatch queues
Queue-Related Technologies
Table3-2 Technologies that use dispatch queues
Implementing Tasks Using Blocks
Creating and Managing Dispatch Queues
Getting the Global Concurrent Dispatch Queues
Creating Serial Dispatch Queues
Listing3-2 Creating a new serial queue
Getting Common Queues at Runtime
Memory Management for Dispatch Queues
Storing Custom Context Information with a Queue
Providing a Clean Up Function For a Queue
Listing3-3 Installing a queue clean up function
Adding Tasks to a Queue
Adding a Single Task to a Queue
Performing a Completion Block When a Task Is Done
Listing3-4 Executing a completion callback after a task
Performing Loop Iterations Concurrently
Listing3-5 Performing the iterations of afor loop concurrently
Performing Tasks on the Main Thread
Using Objective-C Objects in Your Tasks
Waiting on Groups of Queued Tasks
Listing3-6 Waiting on asynchronous tasks
Dispatch Queues and Thread Safety
About Dispatch Sources
Creating Dispatch Sources
Writing and Installing an Event Handler
Table4-1 Getting data from a dispatch source
Installing a Cancellation Handler
Changing the Target Queue
Associating Custom Data with a Dispatch Source
Memory Management for Dispatch Sources
Dispatch Source Examples
Creating a Timer
Listing4-1 Creating a timer dispatch source
Reading Data from a Descriptor
Writing Data to a Descriptor
Monitoring a File-System Object
Listing4-4 Watching for filename changes
Monitoring Signals
Listing4-5 Installing a block to monitor signals
Monitoring a Process
Listing4-6 Monitoring the death of a parent process
Canceling a Dispatch Source
Suspending and Resuming Dispatch Sources
Replacing Threads with Dispatch Queues
Migrating Away from Threads
Eliminating Lock-Based Code
Implementing an Asynchronous Lock
Listing5-1 Modifying protected resources asynchronously
Executing Critical Sections Synchronously
Listing5-2 Running critical sections synchronously
Improving on Loop Code
Listing5-3 Replacing afor loop without striding
Listing5-4 Adding a stride to a dispatched for loop
Replacing Thread Joins
Changing Producer-Consumer Implementations
Replacing Semaphore Code
Replacing Run-Loop Code
Compatibility with POSIX Threads
Document Revision History
0 of .
Results for:
No results containing your search query
P. 1
Con Currency Programming Guide

Con Currency Programming Guide

Ratings: (0)|Views: 1,034|Likes:
Published by kmj0015

More info:

Published by: kmj0015 on Jul 28, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





You're Reading a Free Preview
Pages 4 to 72 are not shown in this preview.
You're Reading a Free Preview
Pages 76 to 78 are not shown in this preview.

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->