When does processItem start executing. Does it start as soon as some items are pushed onto the queue? Or must the for loop finish before the first item on the queue starts e
The simple answer is that all of your tasks will be added to the queue, and then executed in a random (undefined) order.
background information, via https://github.com/caolan/async#queueworker-concurrency
Creates a queue
object with the specified concurrency
. Tasks added to the queue are processed in parallel (up to the concurrency
limit). If all worker
s are in progress, the task
is queued until one becomes available. Once a worker completes a task
, that task
's callback
is called.
In other words, the order is undefined. If you require the tasks to be executed in a particular order, you should be using a different asynchronous primitive, such as series(tasks, [callback])
https://github.com/caolan/async#seriestasks-callback