Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Grand Central Dispatch
Search
nghialv
May 20, 2014
Programming
180
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
30
Presentation for CA.go
nghialv
0
130
A consistent delivery process with GitOps style for any application on any platform
nghialv
0
550
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
370
PipeCD at CyberAgent
nghialv
2
1.2k
Introdution_to_PipeCD.pdf
nghialv
2
750
The Journey of Software Delivery
nghialv
4
470
Monitoring at AbemaTV
nghialv
18
12k
Other Decks in Programming
See All in Programming
Performance Engineering for Everyone
elenatanasoiu
0
270
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
170
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
120
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
590
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
840
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.8k
Creating Composable Callables in Contemporary C++
rollbear
0
200
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
220
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
800
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
110
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Six Lessons from altMBA
skipperchong
29
4.3k
New Earth Scene 8
popppiees
3
2.4k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Speed Design
sergeychernyshev
33
1.9k
The Cult of Friendly URLs
andyhume
79
6.9k
The SEO identity crisis: Don't let AI make you average
varn
0
510
Evolving SEO for Evolving Search Engines
ryanjones
0
240
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Writing Fast Ruby
sferik
630
63k
Code Review Best Practice
trishagee
74
20k
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