node.js - node async queue中这个callback是什么,为什么这里输出只有5行?
PHPz
PHPz 2017-04-17 14:55:30
0
2
653

PHPz
PHPz

学习是最好的投资!

reply all(2)
伊谢尔伦

Of course, because your concurrency is 5, but there is no fork callback in your queue, so the concurrency is 5, and it will not be adjusted until it ends.

var async = require('async');
var q = async.queue(function(data, callback) {
  console.log(data.name);
// fork callback
  callback();
}, 5);
for(var i = 0; i < 10; ++i) {
  q.push({ name: 0 })
}
小葫芦
var q = async.queue(function (data, callback) {
    console.log(data.name);
    callback(null)
},5)

少了callback

An asynchronous function for processing a queued task, which must call its callback(err) argument when finished, with an optional error as an argument. If you want to handle errors from an inpidual task, pass a callback to q.push(). Invoked with (task, callback).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template