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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
23
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
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
550
JavaDoc 再入門
nagise
1
370
The NotImplementedError Problem in Ruby
koic
1
850
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
850
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
210
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
710
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
400
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
6
1.3k
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The SEO Collaboration Effect
kristinabergwall1
1
490
Paper Plane
katiecoart
PRO
1
51k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
For a Future-Friendly Web
brad_frost
183
10k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Paper Plane (Part 1)
katiecoart
PRO
0
9.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
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