Poolp is a project mainly written in JavaScript, based on the MIT license.
Poolp is a NodeJS module to help you manage a pool of custom objects.
Poolp is a basic pool library that will help you manage often reused objects while limiting their concurrent use.
It allows you to define how many different objects can live at the same time, and how long they should live without being used.
var pool = new Poolp(function workerFactory(options, callback) {
if(typeof options !== 'object') {
return callback(new Error('Bad options !'));
}
var myObj = new worker(options);
callback(null, myObj);
});
pool.take({ my: { worker: { options: 'w00t' }}},
function(err, myWorker, release) {
if(err) return console.log('Oops, the creation of my worker failed !');
myWorker.doWork(function() {
console.log('My work is done, release the object for another worker !');
release();
});
});
Create a new pool.
take
function.Ask the pool for an object built with the specified options.
factory
, and will be used to look for existing objects in the queue.take
.By calling this, the pool will stop providing you with new or existing objects. The current objects handled by the pool will finish their work if needed, and be destroyed.
Special thanks to :