HowProgrammingWorks / HowProgrammingWorks/Pool
wrong release function in async example
未關閉
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 8
- 分支
- 10
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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++;
}
}
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
找到包含 release(item) 函式的 async 範例,並檢查排隊中的請求如何接收已釋出的項目。驗證佇列交接以及 free/available 計數,然後執行該範例的 release 行為,以確認直接交給排隊使用者的項目不會同時被計為 free。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100