@pengzhanbo/utils - v3.11.0
    Preparing search index...

    Function createTaskTracker

    • Create a task tracker for promise tasks.

      创建一个 promise 任务追踪器。

      Returns TaskTracker

      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 会立即并发执行任务——这不是锁。 需要限制并发或串行执行时,请使用 SemaphorelimitAsync

      const tracker = createTaskTracker()

      tracker.run(async () => {
      await doSomething()
      })

      // in another context:
      await tracker.wait() // waits for all in-flight tasks to settle
      • Semaphore — for limiting concurrency / 限制并发
      • limitAsync — for serializing executions / 串行执行