Skip to content

Commit

Permalink
* Make webworker-threads an optional dependency.
Browse files Browse the repository at this point in the history
  If WebWorker Threads is unavailable, use vm.createContext
  as a same-thread fallback as before.

  Initial micro-benchmark shows that threads offer 2x throughput
  even when concurrency=1.
  • Loading branch information
audreyt committed Dec 13, 2012
1 parent 7a82251 commit 0f41d20
Show file tree
Hide file tree
Showing 6 changed files with 513 additions and 272 deletions.
36 changes: 30 additions & 6 deletions main.js
Expand Up @@ -86,8 +86,15 @@
snapshot = arg$.snapshot;
if (snapshot) {
ref$ = cb.call(this$.params, snapshot), type = ref$[0], content = ref$[1];
this$.response.type(type);
return this$.response.send(200, content);
if (content instanceof Function) {
return content(SC[this$.params.room], function(rv){
this$.response.type(type);
return this$.response.send(200, rv);
});
} else {
this$.response.type(type);
return this$.response.send(200, content);
}
} else {
this$.response.type(Text);
return this$.response.send(404, '');
Expand All @@ -107,14 +114,24 @@
});
this.get({
'/_/:room/html': api(function(){
var ref$;
return [Html, (ref$ = SC[this.room]) != null ? ref$.CreateSheetHTML() : void 8];
return [
Html, function(sc, cb){
return sc.exportHTML(function(html){
return cb(html);
});
}
];
})
});
this.get({
'/_/:room/csv': api(function(){
var ref$;
return [Csv, (ref$ = SC[this.room]) != null ? ref$.SocialCalc.ConvertSaveToOtherFormat((ref$ = SC[this.room]) != null ? ref$.CreateSheetSave() : void 8, 'csv') : void 8];
return [
Csv, function(sc, cb){
return sc.exportCSV(function(csv){
return cb(csv);
});
}
];
})
});
this.get({
Expand Down Expand Up @@ -189,6 +206,9 @@
continue CleanRoom;
}
}
if ((ref$ = SC[room]) != null) {
ref$.terminate();
}
delete SC[room];
}
}
Expand Down Expand Up @@ -275,6 +295,10 @@
DB.del(['audit', 'log', 'chat', 'ecell', 'snapshot'].map(function(it){
return it + "-" + room;
}), function(){
var ref$;
if ((ref$ = SC[room]) != null) {
ref$.terminate();
}
delete SC[room];
return broadcast(this$.data);
});
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "ethercalc",
"description": "Multi-User Spreadsheet Server",
"version": "0.20121111.0",
"version": "0.20121213.0",
"homepage": "http://ethercalc.net/",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,8 @@
},
"optionalDependencies": {
"hiredis": "0.1.x",
"LiveScript": "1.1.x"
"LiveScript": "1.1.x",
"webworkerThreads": "0.4.x"
},
"directories": {
"bin": "./bin"
Expand Down
4 changes: 3 additions & 1 deletion package.ls 100644 → 100755
@@ -1,6 +1,7 @@
#!/usr/bin/env lsc -cj
name: \ethercalc
description: 'Multi-User Spreadsheet Server'
version: \0.20121111.0
version: \0.20121213.0
homepage: 'http://ethercalc.net/'
repository:
type: 'git'
Expand All @@ -13,6 +14,7 @@ dependencies:
optional-dependencies:
hiredis: \0.1.x
LiveScript: \1.1.x
webworker-threads: \0.4.x
directories:
bin: \./bin
subdomain: \ethercalc
Expand Down

0 comments on commit 0f41d20

Please sign in to comment.