multido

0.0.5 • Public • Published

multido

  • NPM version
  • Dependencies Status
  • Build Status
  • NPM Stats
  • NPM Downloads

create a work group, work group can run job with same action but different parameter.

you can push new job to the group.

like a thread pool, once you push to the group, if current less than specified threads run, this job will run immediately.

if not, will wait a job finish ,then run.

install:

npm install multido

Usage:

var Multido = require('multido');
var worker=function(param,callback){
    // do some thing here
    // callback(); 
    // or
    // callback(err);
    process.nextTick(callback);
}
// errTryCnt, if worker pass error to callback, then group will retry errTryCnt times at most. if not set, will retry forever.
// name, set a name for this group, can use group.getName() to get it back. if not set, will equal to empty string '';
var option = {errTryCnt:3,name:'test_group'};
// limit , allowed threads to run worker at the same time. 
var limit = 3;
var group = new Multido(limit,option,worker);

group.push(param1);
group.push(param2);
group.push(param3);
group.push(param4);
group.push(param5);

Readme

Keywords

Package Sidebar

Install

npm i multido

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • sxyizhiren