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
Concurrent SSJS on the JVM
Search
Philipp Naderer
February 19, 2014
Programming
0
96
Concurrent SSJS on the JVM
Presentation from the Fronteers Jam Session 2012 in Amsterdam.
Philipp Naderer
February 19, 2014
Tweet
Share
More Decks by Philipp Naderer
See All by Philipp Naderer
Im Maschinenraum der Corona-Dashboards
botic
0
24
The Making of a Coronavirus Dashboard
botic
0
69
Seestadt.bot @ Demo Night: Chatbots & Voice Apps
botic
0
88
Seestadt come2gether – StadtKatalog
botic
0
47
Location-aware Documents
botic
0
76
Chatbots @ HacksHackers Munich
botic
0
72
Chatbots @ Mediencamp Vienna
botic
0
150
GEN Editors Lab Munich – BotOx / Team ORF
botic
0
180
Final Master Thesis Presentation
botic
0
110
Other Decks in Programming
See All in Programming
Ruby GitHub Packages
bkuhlmann
0
630
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
8
3.9k
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
670
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
26
8.1k
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
340
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
230
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
150
Folding Cheat Sheet #3
philipschwarz
PRO
0
120
Snowflakeで眠ったデータを起こそう!
estie
0
110
ONE WEDGE_company_guide
1wedge_one
0
430
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
160
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
200
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
186
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
259
12k
Web development in the modern age
philhawksworth
202
10k
Design by the Numbers
sachag
274
18k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
20
1.6k
GitHub's CSS Performance
jonrohan
1024
450k
Bootstrapping a Software Product
garrettdimon
PRO
301
110k
Music & Morning Musume
bryan
41
5.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
16
6.4k
The Language of Interfaces
destraynor
151
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
15
2.6k
Transcript
Concurrent SSJS on the JVM Philipp Naderer / @botic
None
None
RingoJS • JavaScript on the JVM • Based on Mozilla
Rhino • Part of Java SE 6 and Java SE 7 • Successor / Rewrite of Helma • 14 years of SSJS experience!
Features • CommonJS modules & packages • Full access to
Java libraries • ECMAScript 5 and JS 1.8 support • Lots of „ringo/“ modules • dates, http, concurrency, logging, subprocesses, jsgi, command line, ...
Debugger
Threads and SSJS? • Ringo‘s concept: Workers • Implicit multithreaded
code • You can use an EventLoop • No shared global object* • Singletons instead of shared data
myWebApp Module myWebApp Module blocking running running Event Loop
webserver.js var response = require("ringo/jsgi/response"); var {Application} = require("stick"); !
var app = exports.app = new Application(); ! // Configure stick middlewares app.configure("notfound", "route"); ! app.get("/", function(request) { return response.html("<h1>Servas Amsterdam!</h1>"); }); ! if (require.main == module) { require("ringo/httpserver").main(module.id); }
webserver.js serving 10.000 HTTP requests
„Ringo Workers“ • Look like Web Workers in Browsers •
No JSON serialization needed = faster! • Send a message with postMessage(e) • React on message with onMessage(e) • Return the result to the caller with postMessage(e)
fibobuster.js 1. var {Worker} = require("ringo/worker"); 2. 3. // Create
50 Workers = 50 Threads 4. for (var i = 50; i < 100; i++) { 5. var w = new Worker(module.resolve("./fibonacci")); 6. 7. // Callback for the output 8. w.onmessage = function(returnObj) { 9. console.log("Result: " + returnObj.data.result); 10. } 11. 12. // Start with the calculation 13. w.postMessage(i); 14. }
fibonacci.js function onmessage(message) { var limit = message.data; ! console.log("Fibonacci
#" + limit); ! /* Calculate the fibonacci number */ var a = ..., b = ..., c = ...; for (...) { ... } ! message.source.postMessage({ result: c }); }
RingoJS infos • ringojs.org – basic information • github.com/ringojs –
source + examples • @ringojs – official account • @hannesw – Hannes‘ account • IRC: irc.freenode.net #ringojs
None