Skip to content

genichiro/workaholic.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workaholic.js Bower version

Overview

workaholic.js is multi-threading library for Javascript. it employs a worker thread pattern.

Installation

$ bower install --save workaholic.js
<script type="text/javascript" src="./workaholic.js"></script>

Usage

var workaholic = Workaholic.create(2);  // create pool, you can set number of threads

var foo = 3;
var bar = 5;
var baz = 10;
workaholic.execute(
    foo, bar, baz, // before function, you can put as many values as you need
    function(a, b, c) {
        // will run on pooled thread
        var sum = a + b + c;
        finish(sum);  // you must call `finish()` after your work, that can return any value
    }
)
.done(function(result) {
    // get value likes promise chain
});

Demo

run gulp and open http://127.0.0.1:5000/demo

About

worker thread pattern for javascript

Resources

License

Stars

Watchers

Forks

Packages

No packages published