@gmitch215/folio - v1.0.1
    Preparing search index...

    Class TaskPool

    Runs named functions in private contexts on other threads. The owner submits a task with a name and a copied input, keeps working, and joins the copied output. Nothing is shared between the owner and a worker, so tasks must not depend on each other's state; audit checks that. new TaskPool(count) creates the channels. The caller starts each worker, hands it link(index) and calls serveTasks there. new TaskPool(links) attaches to owner ends made by createTaskLinks, for an owner that runs in a worker.

    Index
    • get size(): number

      Number of worker links.

      Returns number

    • get width(): number

      Tasks are spread round robin over the first width workers.

      Returns number

    • set width(value: number): void

      Parameters

      • value: number

      Returns void

    • Closes the channels. Tasks that were not joined are dropped.

      Returns void

    • Blocks the calling thread until the task finishes. Use it where the caller cannot yield.

      Parameters

      • handle: string

      Returns TaskResult

    • Waits for the task without blocking the event loop.

      Parameters

      • handle: string

      Returns Promise<TaskResult>

    • The worker end of link index. List its port in the worker's transferList.

      Parameters

      • index: number

      Returns TaskLink

    • Starts a task and returns a handle for join.

      Parameters

      Returns string

    • Starts a task whose input is a JSON value.

      Parameters

      • name: string
      • value: unknown

      Returns string