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

    Interface TaskTracker

    A tracker for promise tasks.

    A task tracker records in-flight promise tasks and can wait for them to settle. It is NOT a mutual-exclusion lock: tasks submitted via run always execute concurrently, and run never queues or serializes them.

    一个 promise 任务追踪器。

    追踪器登记在途的 promise 任务,并可等待它们全部落定。 它不是互斥锁:通过 run 提交的任务始终并发执行,run 不会排队或串行化任务。

    interface TaskTracker {
        clear: () => void;
        isRunning: () => boolean;
        run: <T = void>(fn: () => Promise<T>) => Promise<T>;
        wait: () => Promise<void>;
    }
    Index
    clear: () => void

    Forget all tracked tasks without cancelling or awaiting them. In-flight tasks keep running; a subsequent wait will not include them.

    清除所有已登记的任务,不会取消或等待它们。在途任务会继续运行;之后调用 wait 不会包含它们。

    isRunning: () => boolean

    Whether there are any in-flight tasks.

    是否存在在途任务。

    run: <T = void>(fn: () => Promise<T>) => Promise<T>

    Run a task and record it as in-flight. The task starts immediately and runs concurrently with any other in-flight tasks.

    启动并登记一个任务。任务立即开始执行,与其他在途任务并发运行。

    Type Declaration

      • <T = void>(fn: () => Promise<T>): Promise<T>
      • Type Parameters

        • T = void

          The type of the resolved value / 解析值的类型

        Parameters

        • fn: () => Promise<T>

          The task to run. 要运行的任务

        Returns Promise<T>

        A promise resolving with the task result. / 解析为任务结果的 promise

    wait: () => Promise<void>

    Wait for all tasks that are in-flight when this method is called to settle. Tasks started afterwards are not included (snapshot semantics). Resolves even if some of the tracked tasks reject.

    等待调用本方法时所有在途的任务落定。 之后新启动的任务不会被包含(快照语义)。即使部分任务拒绝也会正常 resolve。