Skip to content

Commit

Permalink
Add parallel limit. #29
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui Leite committed Dec 10, 2014
1 parent b188d5f commit 12bfbcf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/iconizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ UglifyJS = require('uglify-js'),
mkdirp = require('mkdirp'),
chalk = require('chalk'),
util = require('util'),
os = require('os'),
defaultOptions = {
// svg-sprite options
spritedir : 'icons',
Expand All @@ -39,6 +40,9 @@ defaultOptions = {
preview : null
};


var CONCURRENT_TASKS_LIMIT = os.cpus().length * 2;

/**
* Restore the temporarily altered configuration options
*
Expand Down Expand Up @@ -224,7 +228,9 @@ Iconizr.prototype._svg2png = function(callback) {
if (this._options.verbose) {
console.log('Creating PNG versions of %s SVG images (including the sprite) ...', tasks.length);
}
async.parallel(tasks, function(error) { callback(error); });

// launch talks in parallel with a limit to prevent a flood of process
async.parallelLimit(tasks, CONCURRENT_TASKS_LIMIT, function(error) { callback(error); });
}

/**
Expand Down

0 comments on commit 12bfbcf

Please sign in to comment.