Async nodejs execution order

When the processItem starts. Does this start as soon as some items are queued? Or should the for loop finish before the first element in the queue starts execution?

var processItem = function (item, callback) {
    console.log(item)
    callback();
}


var myQueue = async.queue(processItem, 2)


for (index = 0; index < 1000; ++index) {
    myQueue.push(index)
}
+4
source share
2 answers

The simple answer is that all your tasks will be added to the queue and then executed in random order (undefined).


via https://github.com/caolan/async#queueworker-concurrency

queue (worker, concurrency)

queue concurrency. , , ( concurrency). worker , task , . task, task callback.


, undefined. , , , series(tasks, [callback]) https://github.com/caolan/async#seriestasks-callback

+4

. , ( , ..), , - . : .

JavaScript: , . ( - , , , ..), , .

+2

All Articles