Skip to content

Instantly share code, notes, and snippets.

@ar1g
Last active August 29, 2015 14:17
Show Gist options
  • Save ar1g/6f40454518649223e5f3 to your computer and use it in GitHub Desktop.
Save ar1g/6f40454518649223e5f3 to your computer and use it in GitHub Desktop.
var http = require('http'),
pool = require('threads_a_gogo').createPool(5).all.eval(fib);
function fib(n) {
return (n < 2) ? 1 : (fib(n-2)+fib(n-1));
}
var server = http.createServer(function(req, res) {
pool.any.eval('fib('+req.url.replace('/', '')+')', function(err, data) {
res.writeHead(200);
res.end(data+"\n");
});
}).listen(8000);
console.log("server online at http://localhost:8000/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment