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
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
orange — Client side concurrency made simple
Florian Plank
October 17, 2013
More Decks by Florian Plank
See All by Florian Plank
Ready, set, immersion!
polarblau
0
220
Prototyping all the things
polarblau
2
190
CoffeeScript vs. ECMAScript 6
polarblau
5
3.7k
Design for a complex Reality — Siili Breakfast Edition
polarblau
0
170
Enabling Design for a Complex Reality
polarblau
2
150
A primer on Content Security Policy
polarblau
1
470
Rails and the future of the open web
polarblau
3
150
Brief Ruby/Ruby on Rails intro
polarblau
3
210
Ruby Idioms
polarblau
3
620
Other Decks in Programming
See All in Programming
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
220
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
270
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
860
関数型プログラミングのメリットって何だろう?
wanko_it
0
180
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
210
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
130
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
110
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
140
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.5k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.8k
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
140
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
190
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.4k
Accessibility Awareness
sabderemane
1
160
The Invisible Side of Design
smashingmag
301
52k
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