Closed dead-horse closed 10 years ago
var block = true; function get() { return function (done) { setTimeout(done, block ? 100 : 5); block = false; }; } co(function *() { var tasks = []; for (var i = 0; i < 200; i++) { tasks.push(get()); } var start = Date.now(); yield parallel(tasks, 10); console.log('total used %dms', Date.now() - start); })();
now it won't block by one slow request. the sample total use from 230ms decrease to 160ms
230ms
160ms
thanks!
these code write at midnight just like shit. lol
now it won't block by one slow request. the sample total use from
230ms
decrease to160ms