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
Celluloid & DCell
Search
Patrick Van Stee
July 11, 2012
Programming
620
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Celluloid & DCell
Patrick Van Stee
July 11, 2012
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
141
7.7k
Elixir and Ecto
vanstee
5
1k
Bootstrap
vanstee
8
850
HTTP API Design for iOS Applications
vanstee
11
720
Consensus: An Introduction to Raft
vanstee
21
3.3k
Convergent Replicated Data Types
vanstee
4
890
Pour Over Brewing Method
vanstee
1
430
Map Reduce & Ruby
vanstee
10
920
Other Decks in Programming
See All in Programming
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
660
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
190
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
420
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
560
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
270
Oxlintはいいぞ(続)
yug1224
1
480
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
640
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
230
Deep dive into the select statement (GopherCon UK)
jespino
0
150
Introducing Stack Pull Request in GitHub
kkamegawa
0
110
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
120
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.8k
Making Projects Easy
brettharned
120
6.7k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
410
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
480
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
420
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
820
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Transcript
Celluloid DCell &
@vanstee github.com/vanstee Patrick Van Stee highgroove.com
@tarcieri Revactor Reia nio4r Cryptosphere cool.io
brew install zeromq gem install dcell Setup
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model
class Counter attr_reader :count def initialize @count = 0 end
def increment @count += 1 end end
class Counter attr_reader :count def initialize @count = 0 @mutex
= Mutex.new end def increment @mutex.synchronize do @count += 1 end end end
Threads are hard!
class Counter include Celluloid attr_reader :count def initialize @count =
0 end def increment @count += 1 end end
Actor Model
•No shared state •Communicate with messages •Process messages sequentially
class Counter include Celluloid def increment(count, actor) return count if
count < 10000 actor.increment( count + 1, Actor.current ) end end
& Asynchronous Method Calls Futures
counter = Counter.new # returns immediately counter.increment! puts counter.count #
returns immediately future = counter.future :increment puts future.value
module Enumerable def map(&block) futures = map do |item| Celluloid::Future.new(
item, &block ) end futures.map(&:value) end end
Caveats
• The GIL in MRI does not allow parallelism •
Threads and Fibers are expensive • Concurrency is still a hard problem [not really]
DCell
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model DCell Distributed Celluloid over 0MQ
“I thought of objects being like biological cells or individual
computers on a network, only able to communicate with messages. Alan Kay
• Exposes Actors on the Network • Send messages as
you normally would
DRb DCell Threads Actors
Demo
Also Checkout Sidekiq
github.com celluloid/celluloid celluloid/dcell
Hack Night