diff --git a/src/lib/AsyncPool.ts b/src/lib/AsyncPool.ts index 63814d4..22ed150 100644 --- a/src/lib/AsyncPool.ts +++ b/src/lib/AsyncPool.ts @@ -9,11 +9,12 @@ export class AsyncPool { this.limit = limit; } - async run(task: () => unknown) { + async run(task: () => Promise) { while (this.current >= this.limit) await this.current_changed.wait(); this.update_current(+1); - await task(); + const result = await task(); this.update_current(-1); + return result; } update_current(increment: number) {