wrong release function in async example
未关闭
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- backend
调研方向
找到包含 release(item) 函数的 async 示例,并检查排队的请求如何接收已释放的项目。验证队列交接以及 free/available 计数,然后执行该示例的 release 行为,以确认直接交给排队用户的项目不会同时被计为 free。
由索引模型根据 Issue 内容生成。
描述
release(item) {
const index = this.items.indexOf(item);
if (index < 0) throw new Error('Pool: release unexpected item');
if (this.free[index]) throw new Error('Pool: release not captured');
this.free[index] = true;
this.available++;
if (this.queue.length > 0) {
const { resolve, timer } = this.queue.shift();
clearTimeout(timer);
if (resolve) setTimeout(resolve, 0, item);
}
}
error - we should not free released item if we resolve it for user in queue
release(item) {
const index = this.items.indexOf(item);
if (index < 0) throw new Error('Pool: release unexpected item');
if (this.free[index]) throw new Error('Pool: release not captured');
if (this.queue.length > 0) {
const { resolve, timer } = this.queue.shift();
clearTimeout(timer);
if (resolve) setTimeout(resolve, 0, item);
} else {
this.free[index] = true;
this.available++;
}
}
- 主要语言
- JavaScript
- 星标
- 8
- 派生
- 10
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
Seeed-Studio/wiki-documents#5655 · 2 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
capricorn86/happy-dom#2435 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
Edit: CW+ 未关闭channels:edit check:passed
难度 2/5 1-3 小时 新手友好度 68/100
-
01 type: bug 30 needs: triage 99 tag: UX Accessibility
难度 2/5 1-3 小时 新手友好度 82/100