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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
37
Presentation for CA.go
nghialv
0
130
A consistent delivery process with GitOps style for any application on any platform
nghialv
0
560
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
760
The Journey of Software Delivery
nghialv
4
480
Monitoring at AbemaTV
nghialv
18
12k
Other Decks in Programming
See All in Programming
「人を評価する AI」の設計と実装
ryoyanara
0
240
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
280
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
490
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
210
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
350
メールのエイリアス機能を履き違えない
isshinfunada
0
250
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
160
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
210
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
2
210
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
390
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
380
React本体のコードリーディング
high_g_engineer
1
160
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
530
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
740
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
260
Unsuck your backbone
ammeep
672
58k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
280
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
900
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Raft: Consensus for Rubyists
vanstee
141
7.6k
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