我要哒哒哒offer:可能是你一面表现太好了😂

0 点赞 评论 收藏
分享
offer快到碗里来...:明天周六啥日子啊,我佛了,明天早上10点还有腾讯的面试,三个一起来,一起凉?

0 点赞 评论 收藏
分享
喵哈哈:并发限制k版本,牛客咋不让贴代码了??
class Scheduler {
constructor(limit) {
this.queue = [];
this.limit = limit;
this.currentTaskCount = 0;
}
add(fn) {
return new Promise((resolve, reject) => {
this.queue.push([fn, resolve]);
this.exc();
})
}
exc() {
if (this.currentTaskCount < this.limit && this.queue.length) {
const [fn, resolve] = this.queue.shift();
this.currentTaskCount++;
Promise.resolve(fn()).then((result) => {
resolve(result);
this.currentTaskCount--;
this.exc();
})
}
}
}

0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: