X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=82aef01ea2978115441b468bd9c23dc80decdd3b;hb=31542ddfe8297d3bd0f9cf97a3de06a03dafc15d;hp=b9f6083d82587950875877c2962c4f90e735a921;hpb=d33d2d2fed43d102479c38cc28b496872665a90d;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index b9f6083d..82aef01e 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,4 +1,4 @@ -DynamicThreadPool | poolifier
+DynamicThreadPool | poolifier - v2.6.32
  • Preparing search index...
  • -
  • The search index is not available
poolifier
+
  • The search index is not available
  • poolifier - v2.6.32
    @@ -45,7 +45,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    • DynamicThreadPool
    +
  • Defined in src/pools/thread/dynamic.ts:15
  • @@ -59,7 +59,7 @@ When the maximum number of threads is reached and workers are busy, an event is

    Properties

    emitter? filePath -max +max numberOfWorkers opts promiseResponseMap @@ -71,25 +71,35 @@ When the maximum number of threads is reached and workers are busy, an event is

    Methods

    +
  • Defined in src/pools/thread/dynamic.ts:27
  • Properties

    @@ -149,16 +159,19 @@ When the maximum number of threads is reached and workers are busy, an event is

    Emitter on which events can be listened to.

    Events that can currently be listened to:

      -
    • 'full': Emitted when the pool is dynamic and full.
    • -
    • 'busy': Emitted when the pool is busy.
    • +
    • 'ready': Emitted when the number of workers created in the pool has reached the minimum size expected and are ready.
    • +
    • 'busy': Emitted when the number of workers created in the pool has reached the maximum size expected and are executing at least one task.
    • +
    • 'full': Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.
    • +
    • 'destroy': Emitted when the pool is destroyed.
    • 'error': Emitted when an uncaught error occurs.
    • 'taskError': Emitted when an error occurs while executing a task.
    • +
    • 'backPressure': Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size >= maximum queue size).
    +
  • Defined in src/pools/abstract-pool.ts:65
  • filePath: string
    @@ -167,15 +180,16 @@ When the maximum number of threads is reached and workers are busy, an event is
    -
    +
  • Defined in src/pools/abstract-pool.ts:114
  • +
    max: number

    Maximum number of threads that can be created by this pool.

    +
  • Defined in src/pools/thread/dynamic.ts:29
  • numberOfWorkers: number
    @@ -184,7 +198,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:113
  • @@ -193,11 +207,11 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/thread/fixed.ts:49
  • -
    promiseResponseMap: Map<string, PromiseResponseWrapper<Worker, Response>> = ...
    -

    The execution response promise map.

    +
    promiseResponseMap: Map<string, PromiseResponseWrapper<Response>> = ...
    +

    The task execution response promise map.

    • key: The message id of each submitted task.
    • value: An object that contains the worker, the execution response promise resolve and reject callbacks.
    • @@ -207,7 +221,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:75
  • workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
    @@ -216,16 +230,16 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:81
  • - -
    workerNodes: WorkerNode<Worker, Data>[] = []
    + +
    workerNodes: IWorkerNode<Worker, Data>[] = []

    Pool worker nodes.

    +
  • Defined in src/pools/abstract-pool.ts:62
  • Accessors

    @@ -240,7 +254,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/thread/dynamic.ts:43
    • @@ -253,7 +267,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:675
    • @@ -265,62 +279,87 @@ When the maximum number of threads is reached and workers are busy, an event is
    -
    +
  • Defined in src/pools/abstract-pool.ts:345
  • +
    -
      +
      • get maxSize(): number
      • -

        Pool maximum size.

        +

        The pool maximum size.

        Returns number

    +
  • Defined in src/pools/abstract-pool.ts:546
    • get minSize(): number
    • -

      Pool minimum size.

      +

      The pool minimum size.

      Returns number

    +
  • Defined in src/pools/abstract-pool.ts:539
  • +
    + +
      +
    • get ready(): boolean
    • +
    • +

      The pool readiness boolean status.

      +
      +

      Returns boolean

      +
    • get type(): "fixed" | "dynamic"
    • -

      Pool type.

      +

      The pool type.

      If it is 'dynamic', it provides the max property.

      Returns "fixed" | "dynamic"

    +
  • Defined in src/pools/thread/dynamic.ts:38
  • +
    + +
      +
    • get utilization(): number
    • +
    • +

      The approximate pool utilization.

      +
      +

      Returns number

      The pool utilization.

      + +
      -
    • get worker(): "cluster" | "thread"
    • +
    • get worker(): "thread" | "cluster"
    • -

      Gets the worker type.

      +

      The worker type.

      -

      Returns "cluster" | "thread"

      +

      Returns "thread" | "cluster"

    +
  • Defined in src/pools/thread/fixed.ts:127
  • Methods

      - +
    • Hook executed after the worker task execution. Can be overridden.

      @@ -329,8 +368,8 @@ Can be overridden.

      Parameters

    -
    - +
  • Defined in src/pools/abstract-pool.ts:872
  • +
    +
      - +
    • -

      Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes. +

      Method hooked up after a worker node has been newly created. Can be overridden.

      Parameters

      • -
        worker: Worker
        -

        The newly created worker.

        +
        workerNodeKey: number
        +

        The newly created worker node key.

      Returns void

    +
  • Defined in src/pools/abstract-pool.ts:1144
  • -
    - +
  • Defined in src/pools/abstract-pool.ts:842
  • +
    +
    +
    + +
    -
    - +
  • Defined in src/pools/abstract-pool.ts:1087
  • +
    +
    +
  • Defined in src/pools/abstract-pool.ts:1043
  • +
  • Defined in src/pools/thread/fixed.ts:114
  • -
    - +
  • Defined in src/pools/abstract-pool.ts:787
  • +
    +
    +
  • Defined in src/pools/thread/fixed.ts:60
    • -

      Enables/disables the worker tasks queue in this pool.

      +

      Enables/disables the worker node tasks queue in this pool.

      Parameters

      • enable: boolean
        -

        Whether to enable or disable the worker tasks queue.

        +

        Whether to enable or disable the worker node tasks queue.

      • Optional tasksQueueOptions: TasksQueueOptions
        -

        The worker tasks queue options.

        +

        The worker node tasks queue options.

      Returns void

    +
  • Defined in src/pools/abstract-pool.ts:627
    • - +
    • Executes the specified function in the worker constructor with the task data input parameter.

      @@ -498,12 +553,17 @@ Can be overridden.

      • Optional data: Data
        -

        The task input data for the specified worker function. This can only be structured-cloneable data.

        +

        The optional task input data for the specified task function. This can only be structured-cloneable data.

      • Optional name: string
        -

        The name of the worker function to execute. If not specified, the default worker function will be executed.

        +

        The optional name of the task function to execute. If not specified, the default task function will be executed.

        +
        +
      • +
      • +
        Optional transferList: TransferListItem[]
        +

        An optional array of transferable objects to transfer ownership of. Ownership of the transferred objects is given to the pool's worker_threads worker and they should not be used in the main thread afterwards.

    Returns Promise<Response>

    Promise that will be fulfilled when the task is completed.

    @@ -511,20 +571,76 @@ Can be overridden.

    +
  • Defined in src/pools/abstract-pool.ts:725
  • +
    + +
    +
    + +
    +
    + +
      + +
    • Internal +

      Whether the worker node has back pressure (i.e. its tasks queue is full).

      +
      +
      +

      Parameters

      +
        +
      • +
        workerNodeKey: number
        +

        The worker node key.

        +
        +
      +

      Returns boolean

      true if the worker node has back pressure, false otherwise.

      + +
    • -

      Whether worker nodes are executing at least one task.

      +

      Whether worker nodes are executing concurrently their tasks quota or not.

      Returns boolean

      Worker nodes busyness boolean status.

    +
  • Defined in src/pools/abstract-pool.ts:691
  • +
  • Defined in src/pools/thread/fixed.ts:55
  • +
    + +
    +
    + +
      + +
    • +

      Registers a listener callback on the worker given its worker node key.

      +
      +
      +

      Type Parameters

      +
        +
      • +

        Message

      +
      +

      Parameters

      +
        +
      • +
        workerNodeKey: number
        +

        The worker node key.

        +
        +
      • +
      • +
        listener: ((message) => void)
        +

        The message listener callback.

        +
        +
        +
          +
        • +
            +
          • (message): void
          • +
          • +
            +

            Parameters

            +
            +

            Returns void

      +

      Returns void

      +
    +
    + +
    +
    + +
      - +
    • -

      Sends a message to the given worker.

      +

      Sends a message to worker given its worker node key.

      Parameters

      • -
        worker: Worker
        -

        The worker which should receive the message.

        +
        workerNodeKey: number
        +

        The worker node key.

      • message: MessageValue<Data, unknown>

        The message.

        +
      • +
      • +
        Optional transferList: TransferListItem[]
        +

        The optional array of transferable objects.

        +

      Returns void

    +
  • Defined in src/pools/thread/fixed.ts:77
  • +
  • Defined in src/pools/abstract-pool.ts:639
  • +
  • Defined in src/pools/abstract-pool.ts:594
  • +
  • Defined in src/pools/abstract-pool.ts:613
  • +
  • Defined in src/pools/abstract-pool.ts:826
    • -

      This function is the listener registered for each worker message.

      +

      This method is the listener registered for each worker message.

      Returns ((message) => void)

      The listener function to execute when a message is received from a worker.

      @@ -654,7 +865,7 @@ Can be overridden.

    +
  • Defined in src/pools/abstract-pool.ts:1261