V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  kamilic  ›  全部回复第 11 页 / 共 11 页
回复总数  210
1 ... 2  3  4  5  6  7  8  9  10  11  
2019-11-28 14:41:52 +08:00
回复了 qiayue 创建的主题 推广 [特价][抽奖]赣南脐橙 5 斤试吃装包邮只要 28 元
吃个橙
2019-08-23 13:25:08 +08:00
回复了 VDimos 创建的主题 程序员 这样的想法可行不?
flutter?
2019-07-18 10:02:21 +08:00
回复了 chashao 创建的主题 问与答 一道 promise 的题目,求大佬解答
??不支持 md 的?
2019-07-18 10:01:28 +08:00
回复了 chashao 创建的主题 问与答 一道 promise 的题目,求大佬解答
```javascript
class Scheduler {
constructor() {
this.__maxQueueSize = 2;
this.__runningJobs = [];
this.__pendingQueue = [];
}

get isJobsFull() {
return this.__maxQueueSize <= this.__runningJobs.length;
}

static jobWrapper(promiseCreator) {
Scheduler.__jobId += 1;
const id = Scheduler.__jobId;
const wrappedPromise = promiseCreator().then((result) => {
return {
id,
result
};
});
wrappedPromise.__jobId = id;
return wrappedPromise;
}

removeFinishedJob(id) {
console.log(`remove ${id}`);
this.__runningJobs = this.__runningJobs.reduce((curr, job) => {
if (job.__jobId !== id) {
curr.push(job);
}
return curr;
}, []);
console.log(this.__runningJobs);
}

async add(promiseCreator) {
if (!this.isJobsFull) {
const job = Scheduler.jobWrapper(promiseCreator);
this.__runningJobs.push(job);
const {result, id} = await job;
this.removeFinishedJob(id);
return result;
} else {
this.__pendingQueue.unshift(promiseCreator);
await Promise.race(this.__runningJobs);
if (this.__pendingQueue.length > 0) {
return this.add(this.__pendingQueue.pop());
}
}
}
}

Scheduler.__jobId = 0;
```

昨晚一时兴起写了一下,希望对你有帮助。。
没得选 家就在一线
而且并不是某村村民
2019-05-24 11:01:45 +08:00
回复了 kassol 创建的主题 全球工单系统 淘宝 npm 镜像源貌似挂了
又挂了
2019-04-07 14:37:51 +08:00
回复了 gazce 创建的主题 Apple 就在刚刚,终于打通了 apple 的客服电话。
@BenX AC+ 可以退吗? 我前几天打过电话给客服,他们说服务类的不能退
2018-09-03 11:37:00 +08:00
回复了 wujinglun 创建的主题 程序员 想知道有多少人北上广深港澳的本地人是做 IT 这行的
为什么总觉得土著就是有钱的呢
1 ... 2  3  4  5  6  7  8  9  10  11  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1020 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 19:10 · PVG 03:10 · LAX 12:10 · JFK 15:10
Developed with CodeLauncher
♥ Do have faith in what you're doing.