Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Grand Central Dispatch
Search
nghialv
May 20, 2014
Programming
190
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Grand Central Dispatch
nghialv
May 20, 2014
More Decks by nghialv
See All by nghialv
How LLMs Actually Work
nghialv
0
45
Presentation for CA.go
nghialv
0
140
A consistent delivery process with GitOps style for any application on any platform
nghialv
0
570
How it works - 1.1 - What happens when you run kubectl apply command
nghialv
0
1.1k
Why and how we build a unified CD system
nghialv
0
380
PipeCD at CyberAgent
nghialv
2
1.2k
Introdution_to_PipeCD.pdf
nghialv
2
770
The Journey of Software Delivery
nghialv
4
490
Monitoring at AbemaTV
nghialv
18
12k
Other Decks in Programming
See All in Programming
JIS keyboard support in Omarchy
lef237
0
160
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
150
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
190
sbt 2.0: takeoff
eed3si9n
0
170
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
150
Next.js: The final boss of Web Performance
guaca
0
340
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
210
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
190
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
170
phperだってパンチカードでコーディングしたい
o0h
PRO
0
460
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
250
AI-Powered Domain-Driven Design
ziobrando
0
320
Featured
See All Featured
Designing for Performance
lara
612
70k
Statistics for Hackers
jakevdp
799
230k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
Practical Orchestrator
shlominoach
192
12k
For a Future-Friendly Web
brad_frost
184
10k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
540
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Exploring anti-patterns in Rails
aemeredith
4
540
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Chasing Engaging Ingredients in Design
codingconduct
0
370
Transcript
[iOS multithreading:GCD];
• Multithreading in iOS • Grand Central Dispatch • Queues
• Example
Multithreading in iOS
• Pthreads : C-based interface for creating and manipulating threads
• NSThread : Cocoa threads • Grand Central Dispatch : a lightweight multithreading engine developed by Apple Inc • NSOperation : wrapper for task
Pthreads NSThreads GCD NSOperation complexity low high abstraction level low
high
Grand Central Dispatch
What is GCD? • A lightweight multithreading engine • Uses
a thread pool • Automatically optimizes threading • Scheduling of tasks • Uses look-free exclusion rather than mutual exclusion
• define the tasks • block or function • add
them to an appropriate dispatch queue dispatch_async(queue, ^{ some_async_work(); });
thread thread thread Queue based task task task task task
queue task task task task task queue task task task
Queue types • Serial Queues • only one task running
at a time • user queue or main queue • Concurrent Queue • tasks started in order but run concurrently • 3 priority levels: HIGHT, DEFAULT, LOW
Frequently Used APIs • dispatch_async(queue, block) • dispatch_once(queue, block) •
dispatch_apply(iterations, queue, block) • dispatch_group_async(group, queue, block)
Example
Palindromic words • palindromic words - ճจ • is a
word that reads the same forward as it does backward : “radar” • problem • count the palindromic words in a dictionary radar wrong way yaw result = 3
for (size_t index = 0; index < Words.count; index++) {
NSString *word = [Words objectAtIndex:index]; NSString *reverseString = [self reverseString:word]; if([word caseInsensitiveCompare:reverseString] == NSOrderedSame) { self.palindromicCount++; } else { for (size_t i = index + 1; i < Words.count - 1; i++) { NSString *secondWord = [Words objectAtIndex:i]; if([reverseString caseInsensitiveCompare:secondWord] == NSOrderedSame) { self.palindromicCount += 2; break; } } } }; dispatch_apply(Words.count, queue, ^(size_t index) { NSString *word = [Words objectAtIndex:index]; NSString *reverseString = [self reverseString:word]; if([word caseInsensitiveCompare:reverseString] == NSOrderedSame) { self.palindromicCount++; } else { for (size_t i = index + 1; i < Words.count - 1; i++) { NSString *secondWord = [Words objectAtIndex:i]; if([reverseString caseInsensitiveCompare:secondWord] == NSOrderedSame) { self.palindromicCount += 2; break; } } } });
for (size_t index = 0; index < Words.count; index++) {
NSString *word = [Words objectAtIndex:index]; NSString *reverseString = [self reverseString:word]; if([word caseInsensitiveCompare:reverseString] == NSOrderedSame) { self.palindromicCount++; } else { for (size_t i = index + 1; i < Words.count - 1; i++) { NSString *secondWord = [Words objectAtIndex:i]; if([reverseString caseInsensitiveCompare:secondWord] == NSOrderedSame) { self.palindromicCount += 2; break; } } } }; dispatch_apply(Words.count, queue, ^(size_t index) { NSString *word = [Words objectAtIndex:index]; NSString *reverseString = [self reverseString:word]; if([word caseInsensitiveCompare:reverseString] == NSOrderedSame) { self.palindromicCount++; } else { for (size_t i = index + 1; i < Words.count - 1; i++) { NSString *secondWord = [Words objectAtIndex:i]; if([reverseString caseInsensitiveCompare:secondWord] == NSOrderedSame) { self.palindromicCount += 2; break; } } } });
Results • iPhone 5 : dual-core A6 chip • dictionary
: 25000 words 1.86 times faster Sequential GCD 274s 147s