1.2.0 • Published 6 years ago

multi-threaded-queue v1.2.0

Weekly downloads
49
License
ISC
Repository
github
Last release
6 years ago

multi-threaded-queue

Pure Javascript, simple multi-threaded queue simulation for nodejs

diagram

Usage

var multiThreadedQueue = require('multi-threaded-queue');
var queue = new multiThreadedQueue(size, opt);
  • size: no of simultaneous threads
  • opt: { ..optional.. }
  • autoStart: true, // enable/disable auto start on object insertion, good to use with continuous queue insertion
  • executeFunction: function(obj,next){ .... }, // shorthand for execute function, def. same as below
  • completeFunction: function(){ ... } // shorthand for complete function, def. same as below
// on each object
queue.setExecuteFunction(function(obj,next){
    // perform tasks with picked obj from queue
    .......

    // move to the next on the queue
    next();
});


// on completion
queue.setCompleteFunction(function(){
    // triggered on queue completion
    .......
});

// add objects to the queue
queue.addToQueue(obj);
queue.addToQueue(obj);
.......
queue.addToQueue(obj);

// start processing the queue (not needed if autoStart enabled)
queue.start();

Tests

npm test

Release History

  • 1.0.0 Initial release
  • 1.1.0 Optimizations
  • 1.2.0 GetQueueSize implemented
1.2.0

6 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago