An Introduction To MultithreadedApplications Using Grand Central DispatchDavid Fox - www.davefoxy.com
Multithreading
So What IS GCD?
^{    Prerequisite	 	 Knowledge}
BlocksPortable Chunks Of Code
What’s A Block Look Like?An in-line block            ^{                   // code goes here            }
What’s A Block Look Like?A block stored in a reusable variable
What’s A Block Look Like?A block using a custom block type definition
Back To The Point
The GCD WorkflowCreate a queue to dispatch toDispatch blocks of code to that queueAnd that’s basically it! (sort of)
In Action... An Unresponsive App
Coding Demo Video  View online at www.davefoxy.com
Recap...Create a queue withDispatch blocks of code usingDon’t mess with the UI on other threads
Taking It Further     Dispatch Groups
When Has GCD Finished A Block?Using The Regular dispatch_asyncOutput
When Has GCD Finished A Block?Using A Dispatch GroupOutput
Encapsulating Queues     Using NSOperationQueue
The NSOperationQueue Workflow   Subclasses of NSOperation are created   Typically they override -(void) main   An NSOperati...
Operation Queues In ActionSimple Asynchronous Operations    Note: As OperationA and OperationB are running on the    same ...
Operation Queues In ActionListening For Individual Operation Completion
Operation Queues In ActionWaiting Until An Operation Queue Is Complete Before Continuing
Cancelling An Entire Queue   NSOperationQueues offer a   cancelAllOperations method   All the NSOperations will be notified...
Loads More To ExploreBlocks instead of delegates                              Dispatch Resources   Concurrent Operations  ...
Thanks
Upcoming SlideShare
Loading in …5
×

Multithreaded Applications Using Grand Central Dispatch

4,000 views

Published on

20 minute presentation on using Apple's Grand Central Dispatch for multithreading iOS applications. This talk was given at LiDG by David Fox on the 6th of April 2011.

Published in: Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,000
On SlideShare
0
From Embeds
0
Number of Embeds
160
Actions
Shares
0
Downloads
110
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Multithreaded Applications Using Grand Central Dispatch

  1. 1. An Introduction To MultithreadedApplications Using Grand Central DispatchDavid Fox - www.davefoxy.com
  2. 2. Multithreading
  3. 3. So What IS GCD?
  4. 4. ^{ Prerequisite Knowledge}
  5. 5. BlocksPortable Chunks Of Code
  6. 6. What’s A Block Look Like?An in-line block ^{ // code goes here }
  7. 7. What’s A Block Look Like?A block stored in a reusable variable
  8. 8. What’s A Block Look Like?A block using a custom block type definition
  9. 9. Back To The Point
  10. 10. The GCD WorkflowCreate a queue to dispatch toDispatch blocks of code to that queueAnd that’s basically it! (sort of)
  11. 11. In Action... An Unresponsive App
  12. 12. Coding Demo Video View online at www.davefoxy.com
  13. 13. Recap...Create a queue withDispatch blocks of code usingDon’t mess with the UI on other threads
  14. 14. Taking It Further Dispatch Groups
  15. 15. When Has GCD Finished A Block?Using The Regular dispatch_asyncOutput
  16. 16. When Has GCD Finished A Block?Using A Dispatch GroupOutput
  17. 17. Encapsulating Queues Using NSOperationQueue
  18. 18. The NSOperationQueue Workflow Subclasses of NSOperation are created Typically they override -(void) main An NSOperationQueue is created and NSOperations are added to it The queue is set in action and the operations are executed Queues may be suspended so operations must be aware of this
  19. 19. Operation Queues In ActionSimple Asynchronous Operations Note: As OperationA and OperationB are running on the same queue, operations won’t necessarily finish in the order they’re added.
  20. 20. Operation Queues In ActionListening For Individual Operation Completion
  21. 21. Operation Queues In ActionWaiting Until An Operation Queue Is Complete Before Continuing
  22. 22. Cancelling An Entire Queue NSOperationQueues offer a cancelAllOperations method All the NSOperations will be notified of this They can choose to perform certain actions based upon their isCancelled property Individual operations can be cancelled using cancel
  23. 23. Loads More To ExploreBlocks instead of delegates Dispatch Resources Concurrent Operations SemaphoresDelayed dispatches Check The Apple Documentation
  24. 24. Thanks

×