Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // created by crodas -- Public domain
- // private, number of running processes
- var running = 0;
- // sort of try time
- exports.time = 10;
- // limit, max 5 running processes
- exports.limit = 5;
- exports.exec = function(callback) {
- if (typeof callback != "function") {
- throw ("callback is not a valid function");
- }
- var i = setInterval(function() {
- if (running < exports.limit) {
- running++;
- callback();
- running--;
- clearInterval(i);
- }
- }, exports.time);
- };
Add Comment
Please, Sign In to add comment