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
orange — Client side concurrency made simple
Search
Florian Plank
October 17, 2013
Programming
0
160
orange — Client side concurrency made simple
Florian Plank
October 17, 2013
Tweet
Share
More Decks by Florian Plank
See All by Florian Plank
Ready, set, immersion!
polarblau
0
200
Prototyping all the things
polarblau
2
180
CoffeeScript vs. ECMAScript 6
polarblau
5
3.6k
Design for a complex Reality — Siili Breakfast Edition
polarblau
0
170
Enabling Design for a Complex Reality
polarblau
2
140
A primer on Content Security Policy
polarblau
1
450
Rails and the future of the open web
polarblau
3
140
Brief Ruby/Ruby on Rails intro
polarblau
3
210
Ruby Idioms
polarblau
3
610
Other Decks in Programming
See All in Programming
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.3k
How to stabilize UI tests using XCTest
akkeylab
0
140
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
120
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
150
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
420
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
600
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
160
ロボットのための工場に灯りは要らない
watany
12
3.2k
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
830
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
690
飯MCP
yusukebe
0
380
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
370
Featured
See All Featured
Speed Design
sergeychernyshev
33
1.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
GraphQLとの向き合い方2022年版
quramy
50
14k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.6k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
76
Exploring anti-patterns in Rails
aemeredith
2
290
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
670
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Transcript
orange — Client side concurrency made simple
rubysauna.org
heartrate.js
None
None
None
None
Concurrency
A B C
A B C
A B C
Concurrency is hard
A B C
Concurrency
Barber z z
Barber Customer z z Sleeping?
Barber Customer
Barber Customer Working?
Barber Customer
Barber
Barber Customer
Barber
Barber Customer ?
Barber Customer Crap.
Barber
Barber Customer
Barber z z Crap.
Concurrency in the browser
JavaScript and the golden thread
None
None
None
foo() 10ms 20ms 30ms 40ms click handled click fired setInterval
(10ms)
None
Synchronous —vs— Asynchronous
WebWorkers
JavaScript Thread Worker
Worker JavaScript Thread
Worker Worker JavaScript Thread
Dedicated, Shared & Inline Workers
None
orange
The queue
Define a worker
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> data.numbers.reduce (a, b)-> a
+ b
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> data.numbers.reduce (a, b)-> a
+ b
Create a new job
job = new Orange.Job('sum', numbers: [1..100])
job = new Orange.Job('sum', numbers: [1..100]) job.on 'success', (response) ->
console.log('Sum', response) job.perform()
Events
job.on 'success', (response)-> job.on 'complete', -> job.on 'error', (error)-> job.on
'failure', (error)->
Logging
# workers/sum.coffee importScripts 'orange/worker.js' perform (data)-> log 'The background worker
Gotham deserves ...' data.numbers.reduce (a, b) ->a + b
Batches
batch = new Orange.Batch
batch = new Orange.Batch job = new Orange.Job('sum', [1..100]) batch.push
job batch.perform()
batch = new Orange.Batch [job1, job2, job3]
batch.on 'complete', (jobs) -> batch.on 'job:success', (job) -> batch.on 'job:complete',
(job)-> batch.on 'job:error', (job) -> batch.on 'job:failure', (job) ->
job.getResponse() job.getLastError()
Configuration
Orange.Config.set maxWorkerPoolSize: 4 maxRetries : 3 workersPath : '/lib/workers/'
Retry mechanism and exponential back–off
Error handling
job.on 'error', (error)-> throw error BatchStateTransitionError JobStateTransitionError ResponderNotFoundError …
None
Roadmap >0.2.0
Customized Worker Shim Test coverage Data serialization Benchmarking
Forward arbitrary method calls to worker? Custom events? Instrumentation? Inline
Workers? Helper modules?
Kiitos!
@polarblau