国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

node.js - node async queue中這個callback是什么,為什么這里輸出只有5行?

瀏覽:199日期:2024-08-03 11:53:00

問題描述

node.js - node async queue中這個callback是什么,為什么這里輸出只有5行?

問題解答

回答1:

當然咯,因為你并發量是5,但是你的queue中并沒有fork callback,所以并發量是5,沒有結束也不會調新的咯。

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 })}回答2:

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).

主站蜘蛛池模板: 遂宁市| 宜兴市| 定结县| 湾仔区| 三门峡市| 龙井市| 周宁县| 松溪县| 北安市| 温州市| 石景山区| 镇江市| 石渠县| 旺苍县| 济源市| 安溪县| 海林市| 辛集市| 固镇县| 伊通| 会理县| 海城市| 遂溪县| 务川| 青阳县| 随州市| 乌鲁木齐县| 闸北区| 濮阳县| 丹凤县| 高陵县| 黄浦区| 石河子市| 苏州市| 揭西县| 自治县| 开江县| 自治县| 潼关县| 灌云县| 鹤岗市|