Created
April 7, 2016 07:18
-
-
Save shaikh-shahid/ae521d86d582ee5b0db101ad55d987c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
// Send email | |
var sendEmail = function(email,callback) { | |
console.log("Sending email to "+email); | |
callback(null); | |
} | |
// create a queue object with concurrency 2 | |
var q = async.queue(sendEmail,2); | |
// Called when every processing is done | |
q.drain = function() { | |
console.log('all emails sent'); | |
} | |
// add some emails to the queue | |
q.push(["[email protected]","[email protected]"]); | |
// add email to the front of the queue | |
q.unshift("[email protected]"); | |
//output | |
/* | |
Sending email to [email protected] | |
Sending email to [email protected] | |
Sending email to [email protected] | |
all emails sent | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment