Skip to content

mapbox/workerpoolify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workerpoolify Build Status

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.

Example

main.js

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');

worker.js

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');
        }
    };
};

About

A smart worker pool for Browserify.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published