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
600
4
Share
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.5k
Elixir and Ecto
vanstee
5
990
Bootstrap
vanstee
8
830
HTTP API Design for iOS Applications
vanstee
11
710
Consensus: An Introduction to Raft
vanstee
21
3.2k
Convergent Replicated Data Types
vanstee
4
870
Pour Over Brewing Method
vanstee
1
410
Map Reduce & Ruby
vanstee
10
900
Other Decks in Programming
See All in Programming
分析エージェント精度向上における データアナリストの役割
oura_shoya
0
130
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
710
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
430
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
260
GitHub Copilot CLIのいいところ
htkym
2
1.1k
iOS26時代の新規アプリ開発
yuukiw00w
0
210
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.1k
AIとRubyの静的型付け
ukin0k0
0
190
バックエンドにElysiaJSを採用して気付いた、良い点・悪い点
wanko_it
1
180
Claspは野良GASの夢をみるか
takter00
0
130
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
170
Moments When Things Go Wrong
aurimas
3
120
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
180
We Are The Robots
honzajavorek
0
230
The Limits of Empathy - UXLibs8
cassininazir
1
340
Building AI with AI
inesmontani
PRO
1
1k
Agile that works and the tools we love
rasmusluckow
331
21k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Being A Developer After 40
akosma
91
590k
Faster Mobile Websites
deanohume
310
31k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
230
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
エンジニアに許された特別な時間の終わり
watany
107
240k
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