SlideShare a Scribd company logo
1 of 13
Grand Central Dispatch Dispatch Dispatch
Work dispatch_block_t or dispatch_function_t dispatch_queue_t dispatch_source_t dispatch_group_t Queue
^ { for ( int  i =  0 ; i < something very large; i++) { do_heavy_work(); and_keep_doing_it(); } } dispatch_async (..., );
dispatch_async_f(..., ); function foo(void *context) { for ( int  i =  0 ; i < something very large; i++) { do_heavy_work(); and_keep_doing_it(); } } NULL , &foo
^ { for ( int  i =  0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } } dispatch_sync (..., ); __block int  sum =  0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; ,  @&quot;It's: %d&quot; ,  @&quot;OK&quot; ,  nil ,  nil , sum);
Main queue Global queues dispatch_get_main_queue () dispatch_get_global_queue ( X ,  0 ) DISPATCH_QUEUE_PRIORITY_LOW DISPATCH_QUEUE_PRIORITY_DEFAULT DISPATCH_QUEUE_PRIORITY_HIGH Custom queues dispatch_queue_create() serial concurrent serial
^ { for ( int  i =  0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } } dispatch_async ( dispatch_get_global_queue ( 0 ,  0 ) , ); __block int  sum =  0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; ,  @&quot;It's: %d&quot; ,  @&quot;OK&quot; ,  nil ,  nil , sum);
^ { for ( int  i =  0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_async ( dispatch_get_main_queue () , ); } dispatch_async ( dispatch_get_global_queue ( 0 ,  0 ) , ); __block int  sum =  0 ; ^ { NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; ,  nil ,  nil , sum); }
^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 ,  0 ); dispatch_apply (something very large, global, ); __block int  sum =  0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; ,  nil ,  nil , sum );
^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 ,  0 ); dispatch_apply (something very large, global, ); __block int  sum =  0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; ,  nil ,  nil , sum );
^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 ,  0 ); dispatch_group_t  group =  dispatch_group_create (); for ( int  i =  0 ; i < something very large; i++) { dispatch_group_async (group, queue, ); } __block int  sum =  0 ; dispatch_group_notify (group, queue, ); dispatch_release (group); NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; ,  nil ,  nil , sum );
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
http://mikeash.com/?page=pyblog http://thirdcog.eu/pwcblocks/ http://thirdcog.eu/pwcblocks/ http://thirdcog.eu/pwcblocks/

More Related Content

What's hot

Lec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringLec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringSri Harsha Pamu
 
Computer programing w
Computer programing wComputer programing w
Computer programing wcexpertise
 
Lessons learned from functional programming
Lessons learned from functional programmingLessons learned from functional programming
Lessons learned from functional programmingBryceLohr
 
Functional programming in Swift
Functional programming in SwiftFunctional programming in Swift
Functional programming in SwiftJohn Pham
 
Insert element position
Insert element positionInsert element position
Insert element positionKavya Shree
 
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べSwift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べTaketo Sano
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c mohdshanu
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers mohdshanu
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for ScientistsAndreas Dewes
 
Computer notes - Hashing
Computer notes - HashingComputer notes - Hashing
Computer notes - Hashingecomputernotes
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sortShanmuga Raju
 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffffmohdshanu
 

What's hot (19)

week-10x
week-10xweek-10x
week-10x
 
PyLecture2 -NetworkX-
PyLecture2 -NetworkX-PyLecture2 -NetworkX-
PyLecture2 -NetworkX-
 
12 1 문자열
12 1 문자열12 1 문자열
12 1 문자열
 
Array
ArrayArray
Array
 
Progr2
Progr2Progr2
Progr2
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Lec21-CS110 Computational Engineering
Lec21-CS110 Computational EngineeringLec21-CS110 Computational Engineering
Lec21-CS110 Computational Engineering
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
Lessons learned from functional programming
Lessons learned from functional programmingLessons learned from functional programming
Lessons learned from functional programming
 
Functional programming in Swift
Functional programming in SwiftFunctional programming in Swift
Functional programming in Swift
 
Insert element position
Insert element positionInsert element position
Insert element position
 
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べSwift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for Scientists
 
Computer notes - Hashing
Computer notes - HashingComputer notes - Hashing
Computer notes - Hashing
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sort
 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffff
 

Viewers also liked

Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheid
Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheidBedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheid
Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheidPeter Keur
 
Ray searches
Ray searchesRay searches
Ray searchesDi Dawson
 
Akhuwat Leading organization through innovation 21042015
Akhuwat Leading organization through innovation 21042015Akhuwat Leading organization through innovation 21042015
Akhuwat Leading organization through innovation 21042015Akhuwat
 
Preferred method of working
Preferred method of workingPreferred method of working
Preferred method of workingDi Dawson
 
WSU Spokane Historical Talk
WSU Spokane Historical TalkWSU Spokane Historical Talk
WSU Spokane Historical TalkLarry Cebula
 
ICT op school, niet bij leren alleen
ICT op school, niet bij leren alleenICT op school, niet bij leren alleen
ICT op school, niet bij leren alleenPeter Keur
 
Taaleem Foundation Schools
Taaleem Foundation SchoolsTaaleem Foundation Schools
Taaleem Foundation SchoolsAkhuwat
 
20110310 zenc kennisnet presentatie missing link v7
20110310 zenc kennisnet presentatie missing link v720110310 zenc kennisnet presentatie missing link v7
20110310 zenc kennisnet presentatie missing link v7Peter Keur
 
Taaleem Foundation Schools Balochistan
Taaleem Foundation Schools BalochistanTaaleem Foundation Schools Balochistan
Taaleem Foundation Schools BalochistanAkhuwat
 
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24Joachim Bengtsson
 
Pubblicità Progresso e Comunicazione Sociale
Pubblicità Progresso e Comunicazione SocialePubblicità Progresso e Comunicazione Sociale
Pubblicità Progresso e Comunicazione Socialepaolopappalardo
 
Ed Ibriefpowerpoint
Ed IbriefpowerpointEd Ibriefpowerpoint
Ed IbriefpowerpointDi Dawson
 
Pakistan strengths
Pakistan strengthsPakistan strengths
Pakistan strengthsAkhuwat
 
België als infrastructuur
België als infrastructuurBelgië als infrastructuur
België als infrastructuurPeter Keur
 

Viewers also liked (15)

Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheid
Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheidBedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheid
Bedrijf Zoekt App 2011 - Apps - Grondstof voor processen bij de overheid
 
Endometrioziz
EndometriozizEndometrioziz
Endometrioziz
 
Ray searches
Ray searchesRay searches
Ray searches
 
Akhuwat Leading organization through innovation 21042015
Akhuwat Leading organization through innovation 21042015Akhuwat Leading organization through innovation 21042015
Akhuwat Leading organization through innovation 21042015
 
Preferred method of working
Preferred method of workingPreferred method of working
Preferred method of working
 
WSU Spokane Historical Talk
WSU Spokane Historical TalkWSU Spokane Historical Talk
WSU Spokane Historical Talk
 
ICT op school, niet bij leren alleen
ICT op school, niet bij leren alleenICT op school, niet bij leren alleen
ICT op school, niet bij leren alleen
 
Taaleem Foundation Schools
Taaleem Foundation SchoolsTaaleem Foundation Schools
Taaleem Foundation Schools
 
20110310 zenc kennisnet presentatie missing link v7
20110310 zenc kennisnet presentatie missing link v720110310 zenc kennisnet presentatie missing link v7
20110310 zenc kennisnet presentatie missing link v7
 
Taaleem Foundation Schools Balochistan
Taaleem Foundation Schools BalochistanTaaleem Foundation Schools Balochistan
Taaleem Foundation Schools Balochistan
 
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
 
Pubblicità Progresso e Comunicazione Sociale
Pubblicità Progresso e Comunicazione SocialePubblicità Progresso e Comunicazione Sociale
Pubblicità Progresso e Comunicazione Sociale
 
Ed Ibriefpowerpoint
Ed IbriefpowerpointEd Ibriefpowerpoint
Ed Ibriefpowerpoint
 
Pakistan strengths
Pakistan strengthsPakistan strengths
Pakistan strengths
 
België als infrastructuur
België als infrastructuurBelgië als infrastructuur
België als infrastructuur
 

Similar to Grand Central Dispatch

Similar to Grand Central Dispatch (20)

Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Arrays
ArraysArrays
Arrays
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
 
week-17x
week-17xweek-17x
week-17x
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
C programming
C programmingC programming
C programming
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Sbaw090623
Sbaw090623Sbaw090623
Sbaw090623
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdf
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 

Recently uploaded

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Recently uploaded (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

Grand Central Dispatch

  • 1. Grand Central Dispatch Dispatch Dispatch
  • 2. Work dispatch_block_t or dispatch_function_t dispatch_queue_t dispatch_source_t dispatch_group_t Queue
  • 3. ^ { for ( int i = 0 ; i < something very large; i++) { do_heavy_work(); and_keep_doing_it(); } } dispatch_async (..., );
  • 4. dispatch_async_f(..., ); function foo(void *context) { for ( int i = 0 ; i < something very large; i++) { do_heavy_work(); and_keep_doing_it(); } } NULL , &foo
  • 5. ^ { for ( int i = 0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } } dispatch_sync (..., ); __block int sum = 0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum);
  • 6. Main queue Global queues dispatch_get_main_queue () dispatch_get_global_queue ( X , 0 ) DISPATCH_QUEUE_PRIORITY_LOW DISPATCH_QUEUE_PRIORITY_DEFAULT DISPATCH_QUEUE_PRIORITY_HIGH Custom queues dispatch_queue_create() serial concurrent serial
  • 7. ^ { for ( int i = 0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } } dispatch_async ( dispatch_get_global_queue ( 0 , 0 ) , ); __block int sum = 0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum);
  • 8. ^ { for ( int i = 0 ; i < something very large; i++) { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_async ( dispatch_get_main_queue () , ); } dispatch_async ( dispatch_get_global_queue ( 0 , 0 ) , ); __block int sum = 0 ; ^ { NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum); }
  • 9. ^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 , 0 ); dispatch_apply (something very large, global, ); __block int sum = 0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum );
  • 10. ^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 , 0 ); dispatch_apply (something very large, global, ); __block int sum = 0 ; NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum );
  • 11. ^ { do_heavy_work(); sum += and_keep_doing_it(); } dispatch_queue_t global = dispatch_get_global_queue( 0 , 0 ); dispatch_group_t group = dispatch_group_create (); for ( int i = 0 ; i < something very large; i++) { dispatch_group_async (group, queue, ); } __block int sum = 0 ; dispatch_group_notify (group, queue, ); dispatch_release (group); NSRunAlertPanel ( @&quot;Found the sum!&quot; , @&quot;It's: %d&quot; , @&quot;OK&quot; , nil , nil , sum );
  • 12.