lemmings
A small process queuing manager
Extracted from music.json
Why?
Initially used to limit the number of child processes spawned on async exec
calls. Spawning too many child processes can lead to Error: spawn EMFILE
which
is no good on massively asynchronous script (music.json in my case).
Usage
$ npm install lemmings
// lemming_example.js var Lemmings = ; // Initialize and set max concurrent processes to 2 var lemmings = 8; // Declare function to be called when all jobs completed lemmings{ console; }; // Random Async Task { ; }; // Run various tasks forvar i = 0; i < 5; i++ // Input function into Lemmings#try lemmings; lemmings; lemmings; ;
Results (may vary)
$ node lemming_example.js Digging... Parachuting... Digging... Building steps... Parachuting... Building steps... Digging... Digging... Parachuting... Digging... Parachuting... Building steps... Building steps... Parachuting... Building steps... Lemmings have completed the level.
Notes
- Assumes only one async call per Lemmings#try i.e. function passed into Lemmings#try should only contain one async call (fixed in future updates)
Need to add Gruntfile
License
Lemmings is released under the MIT License.