X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=c6a56f040a48d913de8cb6390ee465ee7773f65a;hb=a2742ce794032ee57b3ec1203c500b1aecca34f0;hp=f37212823c64232387ff0844861ca97422139b4e;hpb=d655c2c2b159a39f900230c14b301ba123653362;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index f3721282..c6a56f04 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,4 +1,4 @@ -DynamicThreadPool | poolifier
+DynamicThreadPool | poolifier
-
+

Type Parameters

-
    +
    • -

      Data = unknown

      +

      Data = unknown

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

    • -

      Response = unknown

      +

      Response = unknown

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

Hierarchy

+
  • Defined in src/pools/thread/dynamic.ts:15
  • @@ -50,138 +50,140 @@ When the maximum number of threads is reached and workers are busy, an event is

    Constructors

    -
    +
    -
      - +
        +
      • Constructs a new poolifier dynamic thread pool.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

    Parameters

    • -
      min: number
      +
      min: number

      Minimum number of threads which are always active.

    • -
      max: number
      +
      max: number

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

    • -
      filePath: string
      +
      filePath: string

      Path to an implementation of a ThreadWorker file, which can be relative or absolute.

    • -
      opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
      +
      opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}

      Options for this dynamic thread pool.

    -

    Returns DynamicThreadPool<Data, Response>

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

    -
    +
    -
    emitter?: PoolEmitter
    +
    emitter?: PoolEmitter

    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.
    • +
    • 'error': Emitted when an uncaught error occurs.
    • +
    • 'taskError': Emitted when an error occurs while executing a task.
    -
    +
  • Defined in src/pools/abstract-pool.ts:46
  • +
    -
    filePath: string
    -

    Path to the worker-file.

    +
    filePath: string
    +

    Path to the worker file.

    -
    +
  • Defined in src/pools/abstract-pool.ts:81
  • +
    -
    max: number
    +
    max: number

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

    -
    +
  • Defined in src/pools/thread/dynamic.ts:29
  • +
    -
    numberOfWorkers: number
    +
    numberOfWorkers: number

    Number of workers that this pool should manage.

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

    Options for the pool.

    -
    +
  • Defined in src/pools/abstract-pool.ts:82
  • +
    -
    promiseResponseMap: Map<string, PromiseResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
    +
    promiseResponseMap: Map<string, PromiseResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...

    The execution response promise map.

    • key: The message id of each submitted task.
    • @@ -191,29 +193,29 @@ When the maximum number of threads is reached and workers are busy, an event is
    -
    +
  • Defined in src/pools/abstract-pool.ts:56
  • +
    -
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    +
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>

    Worker choice strategy context referencing a worker choice algorithm implementation.

    Default to a round robin algorithm.

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

    Pool worker nodes.

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

    -
    +
    -
      +
      • get busy(): boolean
      • Whether the pool is busy or not.

        @@ -222,10 +224,10 @@ When the maximum number of threads is reached and workers are busy, an event is

        Returns boolean

    -
    +
  • Defined in src/pools/thread/dynamic.ts:52
  • +
    -
      +
      • get full(): boolean
      • Whether the pool is full or not.

        @@ -234,47 +236,58 @@ When the maximum number of threads is reached and workers are busy, an event is

        Returns boolean

    -
    - -
    +
    + +
    +
    + +
      +
    • get maxSize(): number
    • +
    • +

      Pool maximum size.

      Returns number

    -
    - -
    +
    + +
      +
    • get minSize(): number
    • -

      Number of tasks running in the pool.

      +

      Pool minimum size.

      Returns number

    -
    +
  • Defined in src/pools/thread/fixed.ts:99
  • +
    -
      -
    • get type(): PoolType
    • +
        +
      • get type(): "fixed" | "dynamic"
      • Pool type.

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

        -

        Returns PoolType

    +
  • Defined in src/pools/thread/dynamic.ts:37
  • Methods

    -
    +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:450
  • +
    -
    -
    +
  • Defined in src/pools/thread/fixed.ts:84
  • +
    -
      - +
        +
      • Hook executed before the worker task execution. Can be overridden.

        @@ -325,66 +338,64 @@ Can be overridden.

        Parameters

        • -
          workerNodeKey: number
          +
          workerNodeKey: number

          The worker node key.

        Returns void

    -
    +
  • Defined in src/pools/abstract-pool.ts:439
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:518
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:581
  • +
    -
    -
    +
  • Defined in src/pools/thread/fixed.ts:77
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:402
  • +
    -
    -

    Returns Promise<void>

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

        Executes the function specified in the constructor with the task data parameter.

        - -

        Returns

        Promise that will be resolved when the task is successfully completed.

        +

        Executes the specified function in the worker constructor with the task data input parameter.

        Parameters

        • -
          data: Data
          -

          The input for the specified task. This can only be serializable data.

          +
          Optional data: Data
          +

          The task input data for the specified worker function. This can only be serializable data.

          +
        • +
        • +
          Optional name: string
          +

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

        -

        Returns Promise<Response>

    -
    - -
      - -
    • -

      Finds a free worker node key based on the number of tasks the worker has applied.

      -

      If a worker is found with 0 running tasks, it is detected as free and its worker node key is returned.

      -

      If no free worker is found, -1 is returned.

      - -

      Returns

      A worker node key if there is one, -1 otherwise.

      -
      -

      Returns number

    -
    +
  • Defined in src/pools/abstract-pool.ts:367
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:358
  • +
    -
    -
    +
  • Defined in src/pools/thread/fixed.ts:48
  • +
    -
      - +
        +
      • Registers a listener callback on the given worker.

        -
        +

        Type Parameters

        -
          +
          • -

            Message

        +

        Message

    Parameters

    Returns void

    Returns void

    -
    +
  • Defined in src/pools/thread/fixed.ts:69
  • +
    -
    -
    +
  • Defined in src/pools/thread/fixed.ts:61
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:326
  • +
    -
      - +
        +
      • Sets the worker choice strategy in this pool.

        @@ -565,21 +564,21 @@ Can be overridden.

        Parameters

        • -
          workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
          +
          workerChoiceStrategy: "ROUND_ROBIN" | "LEAST_USED" | "LEAST_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN" | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"

          The worker choice strategy.

        • -
          Optional workerChoiceStrategyOptions: WorkerChoiceStrategyOptions
          +
          Optional workerChoiceStrategyOptions: WorkerChoiceStrategyOptions

          The worker choice strategy options.

        Returns void

    -
    +
  • Defined in src/pools/abstract-pool.ts:273
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:303
  • +
    -
      - +
    -
    +
  • Defined in src/pools/abstract-pool.ts:424
  • +
    -
      - +
        +
      • This function is the listener registered for each worker message.

        - -

        Returns

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

        -

        Returns ((message: MessageValue<Response, unknown>) => void)

        +

        Returns ((message) => void)

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

        +
        • -
            -
          • (message: MessageValue<Response, unknown>): void
          • +
              +
            • (message): void
            • This function is the listener registered for each worker message.

              - -

              Returns

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

              Parameters

              -

              Returns void

        +

        Returns void

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

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

    Theme

    On This Page

    +
  • constructor
  • +
  • emitter
  • +
  • filePath
  • +
  • max
  • +
  • numberOfWorkers
  • +
  • opts
  • +
  • promiseResponseMap
  • +
  • workerChoiceStrategyContext
  • +
  • workerNodes
  • +
  • busy
  • +
  • full
  • +
  • info
  • +
  • maxSize
  • +
  • minSize
  • +
  • type
  • +
  • afterTaskExecutionHook
  • +
  • afterWorkerSetup
  • +
  • beforeTaskExecutionHook
  • +
  • chooseWorkerNode
  • +
  • createAndSetupWorker
  • +
  • createWorker
  • +
  • destroy
  • +
  • destroyWorker
  • +
  • enableTasksQueue
  • +
  • execute
  • +
  • internalBusy
  • +
  • isMain
  • +
  • registerWorkerMessageListener
  • +
  • sendToWorker
  • +
  • setTasksQueueOptions
  • +
  • setWorkerChoiceStrategy
  • +
  • setWorkerChoiceStrategyOptions
  • +
  • setupHook
  • +
  • workerListener
  • +
  • AbstractPool
  • +
  • AbstractWorker
  • +
  • CircularArray
  • +
  • ClusterWorker
  • +
  • DynamicClusterPool
  • +
  • DynamicThreadPool
  • +
  • FixedClusterPool
  • +
  • FixedThreadPool
  • +
  • PoolEmitter
  • +
  • Queue
  • +
  • ThreadWorker
  • +
  • WorkerChoiceStrategyContext
  • +
  • ClusterPoolOptions
  • +
  • IPool
  • +
  • IWorker
  • +
  • IWorkerChoiceStrategy
  • +
  • MessageValue
  • +
  • PoolInfo
  • +
  • PoolOptions
  • +
  • PromiseResponseWrapper
  • +
  • RequiredStatistics
  • +
  • Task
  • +
  • TasksQueueOptions
  • +
  • TasksUsage
  • +
  • WorkerChoiceStrategyOptions
  • +
  • WorkerNode
  • +
  • WorkerOptions
  • +
  • Draft
  • +
  • ErrorHandler
  • +
  • ExitHandler
  • +
  • KillBehavior
  • +
  • MessageHandler
  • +
  • OnlineHandler
  • +
  • PoolEvent
  • +
  • PoolType
  • +
  • TaskFunctions
  • +
  • ThreadWorkerWithMessageChannel
  • +
  • WorkerAsyncFunction
  • +
  • WorkerChoiceStrategy
  • +
  • WorkerFunction
  • +
  • WorkerSyncFunction
  • +
  • KillBehaviors
  • +
  • PoolEvents
  • +
  • PoolTypes
  • +
  • WorkerChoiceStrategies
  • Generated using TypeDoc

    \ No newline at end of file