An experimental worker pool for Browserify-bundled projects. Unlike webworkify, it allows you to create many lightweight "workers" with an N:M ratio to a pool of native web workers.
When you create a new pooled worker, its module dependencies are lazily loaded on the worker side with some clever tricks.
var workerpoolify = require('workerpoolify');
var PooledWorker = workerpoolify(4);
var worker = new PooledWorker(require('./worker'));
worker.onmessage = function (type, data) {
if (type === 'foo') {
console.log('got message foo');
}
};
worker.send('bar');
module.exports = function TestWorker() {
console.log('worker created');
this.onmessage = function (type, data) {
if (type === 'bar') {
console.log('worker: got message bar');
this.send('foo');
}
};
};