X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=e9f33e6bacfeac5a43afe2d134ce5ad9a3b9fc83;hb=25926072f5397949802f6af5a2f7d49d6f15cacc;hp=9f0a4654cc89de0ae8ab7f0b2b13786edd4f14de;hpb=aac8863d208eadcb0ecb33dc44d045c26f5a444f;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 9f0a4654..e9f33e6b 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,13 +1,13 @@ -DynamicThreadPool | poolifier
+DynamicThreadPool | poolifier - v2.7.4
-
+
  • The search index is not available
  • poolifier - v2.7.4 +
    @@ -30,12 +30,12 @@ When the maximum number of threads is reached and workers are busy, an event is
    • Data = unknown

      -

      Type of data sent to the worker. This can only be serializable data.

      +

      Type of data sent to the worker. This can only be structured-cloneable data.

    • Response = unknown

      -

      Type of execution response. This can only be serializable data.

      +

      Type of execution response. This can only be structured-cloneable data.

    @@ -45,21 +45,21 @@ When the maximum number of threads is reached and workers are busy, an event is
    • DynamicThreadPool
    +
  • Defined in src/pools/thread/dynamic.ts:16
  • - +

    Constructors

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

    - -
    emitter?: PoolEmitter
    -

    Emitter on which events can be listened to.

    + +
    emitter?: __module | EventEmitterAsyncResource
    +

    Event emitter integrated with async resource on which events can be listened to. +The async tracking tooling identifier is poolifier:<PoolType>-<WorkerType>-pool.

    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 concurrently their tasks quota.
    • +
    • '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:73
  • filePath: string
    @@ -168,15 +187,16 @@ When the maximum number of threads is reached and workers are busy, an event is
    -
    +
  • Defined in src/pools/abstract-pool.ts:128
  • +
    max: number

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

    +
  • Defined in src/pools/thread/dynamic.ts:30
  • numberOfWorkers: number
    @@ -185,7 +205,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:127
  • @@ -194,11 +214,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<ThreadWorkerWithMessageChannel, 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.
    • @@ -208,25 +228,25 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:82
  • -
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    +
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>

    Worker choice strategy context referencing a worker choice algorithm implementation.

    +
  • Defined in src/pools/abstract-pool.ts:88
  • - -
    workerNodes: WorkerNode<ThreadWorkerWithMessageChannel, Data>[] = []
    + +
    workerNodes: IWorkerNode<Worker, Data>[] = []

    Pool worker nodes.

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

    @@ -241,7 +261,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/thread/dynamic.ts:44
    • @@ -254,7 +274,7 @@ When the maximum number of threads is reached and workers are busy, an event is
    +
  • Defined in src/pools/abstract-pool.ts:651
    • @@ -266,62 +286,118 @@ When the maximum number of threads is reached and workers are busy, an event is
    -
    +
  • Defined in src/pools/abstract-pool.ts:271
  • +
    -
      +
      • get maxSize(): number
      • -

        Pool maximum size.

        +

        The pool maximum size.

        Returns number

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

      Pool minimum size.

      +

      The pool minimum size.

      Returns number

    +
  • Defined in src/pools/abstract-pool.ts:477
  • +
    + +
      +
    • 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:39
  • +
    + +
      +
    • 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:149
  • Methods

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

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

      -

      Can be used to update the maxListeners or binding the main-worker<->worker connection if not bind by default.

      +

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

      Parameters

      Returns void

    +
  • Defined in src/pools/abstract-pool.ts:1346
  • -
    - +
  • Defined in src/pools/abstract-pool.ts:1005
  • +
    +
    -
    - +
  • Defined in src/pools/abstract-pool.ts:1252
  • +
    +
    +
  • Defined in src/pools/abstract-pool.ts:1208
  • +
  • Defined in src/pools/thread/fixed.ts:136
  • +
    + +
      + +
    • +

      Deregisters 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

      +
    -
    - +
  • Defined in src/pools/abstract-pool.ts:940
  • +
    +
    +
  • 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:565
    • - +
    • Executes the specified function in the worker constructor with the task data input parameter.

      @@ -499,12 +616,17 @@ Can be overridden.

      • Optional data: Data
        -

        The task input data for the specified worker function. This can only be serializable 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.

    @@ -512,16 +634,97 @@ Can be overridden.

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

      Whether the specified task function exists in this pool.

      +
      +
      +

      Parameters

      +
        +
      • +
        name: string
        +

        The name of the task function.

        +
        +
      +

      Returns boolean

      true if the task function exists, false otherwise.

      + +
    +
    + +
      + +
    • 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.

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

      Registers once 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

      +
      - +
    • -

      Registers a listener callback on the given worker.

      +

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

      Type Parameters

      @@ -550,8 +807,8 @@ Can be overridden.

      Parameters

      • -
        worker: ThreadWorkerWithMessageChannel
        -

        The worker which should register a listener.

        +
        workerNodeKey: number
        +

        The worker node key.

      • @@ -568,58 +825,139 @@ Can be overridden.

        Parameters

        • -
          message: MessageValue<Message, unknown, Worker | MessagePort>
      +
      message: MessageValue<Message, unknown>

    Returns void

    Returns void

    +
  • Defined in src/pools/thread/fixed.ts:106
  • +
    + +
    +
    + +
    +
    + +
    +
  • Defined in src/pools/thread/fixed.ts:77
  • +
    + +
    +
  • Defined in src/pools/abstract-pool.ts:579
  • +
  • Defined in src/pools/abstract-pool.ts:532
  • +
  • Defined in src/pools/abstract-pool.ts:551
  • +
  • Defined in src/pools/abstract-pool.ts:989
  • +
    + +
    +
  • Defined in src/pools/abstract-pool.ts:1497
  • @@ -728,7 +1078,7 @@ Can be overridden

  • constructor
  • emitter
  • filePath
  • -
  • max
  • +
  • max
  • numberOfWorkers
  • opts
  • promiseResponseMap
  • @@ -737,90 +1087,69 @@ Can be overridden

  • busy
  • full
  • info
  • -
  • maxSize
  • +
  • maxSize
  • minSize
  • +
  • ready
  • type
  • +
  • utilization
  • worker
  • +
  • addTaskFunction
  • afterTaskExecutionHook
  • -
  • afterWorkerSetup
  • +
  • afterWorkerNodeSetup
  • beforeTaskExecutionHook
  • -
  • chooseWorkerNode
  • -
  • createAndSetupWorker
  • +
  • createAndSetupDynamicWorkerNode
  • +
  • createAndSetupWorkerNode
  • createWorker
  • +
  • deregisterWorkerMessageListener
  • destroy
  • -
  • destroyWorker
  • +
  • destroyWorkerNode
  • enableTasksQueue
  • execute
  • +
  • flushTasksQueue
  • +
  • getWorkerInfo
  • +
  • hasTaskFunction
  • +
  • hasWorkerNodeBackPressure
  • internalBusy
  • isMain
  • +
  • listTaskFunctionNames
  • +
  • registerOnceWorkerMessageListener
  • registerWorkerMessageListener
  • +
  • removeTaskFunction
  • +
  • sendKillMessageToWorker
  • +
  • sendStartupMessageToWorker
  • sendToWorker
  • +
  • setDefaultTaskFunction
  • setTasksQueueOptions
  • setWorkerChoiceStrategy
  • setWorkerChoiceStrategyOptions
  • setupHook
  • +
  • start
  • workerListener
  • +
    -

    Generated using TypeDoc

    -
    \ No newline at end of file +

    Generated using TypeDoc

    +
    \ No newline at end of file