The task tracker. / 任务追踪器
run executes tasks immediately and concurrently — this is not a lock.
Use Semaphore or limitAsync when you need to limit concurrency
or serialize executions.
run 会立即并发执行任务——这不是锁。
需要限制并发或串行执行时,请使用 Semaphore 或 limitAsync。
const tracker = createTaskTracker()
tracker.run(async () => {
await doSomething()
})
// in another context:
await tracker.wait() // waits for all in-flight tasks to settle
Create a task tracker for promise tasks.
创建一个 promise 任务追踪器。