blob: cd61e83b0bcd4319b211459e6f9715ffbf961dd6 [file]
// a simple worker for use in node.js (as a child process)
// load workerpool
var workerpool = require('../..');
// a deliberately inefficient implementation of the fibonacci sequence
function fibonacci(n) {
if (n < 2) return n;
return fibonacci(n - 2) + fibonacci(n - 1);
}
// create a worker and register public functions
workerpool.worker({
fibonacci: fibonacci
});