multi-threaded-queue

1.2.0 • Public • Published

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

/multi-threaded-queue/

    Package Sidebar

    Install

    npm i multi-threaded-queue

    Weekly Downloads

    6

    Version

    1.2.0

    License

    ISC

    Unpacked Size

    47.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • prabhathkm