X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=e9f33e6bacfeac5a43afe2d134ce5ad9a3b9fc83;hb=25926072f5397949802f6af5a2f7d49d6f15cacc;hp=de2edc9d8649f9a8a2c83a1386b686ddedd67699;hpb=8d98e603c79d8d00b2b6a33e5f732701a7466234;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index de2edc9d..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 +
    @@ -19,22 +19,25 @@

    A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.

    This thread pool creates new threads when the others are busy, up to the maximum number of threads. When the maximum number of threads is reached and workers are busy, an event is emitted. If you want to listen to this event, use the pool's emitter.

    +
    +
    +

    Author

    Alessandro Pio Ardizio

    -

    Author

    Alessandro Pio Ardizio

    - -

    Since

    0.0.1

    +

    Since

    0.0.1

    Type Parameters

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

    +
    +

    Hierarchy

      @@ -42,65 +45,80 @@ 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

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

      @@ -117,189 +135,269 @@ When the maximum number of threads is reached and workers are busy, an event is
    • min: number

      Minimum number of threads which are always active.

      -
    • +
    +
  • max: number

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

    -
  • +
    +
  • filePath: string

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

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

    Options for this dynamic thread pool.

    -
  • -

    Returns DynamicThreadPool<Data, Response>

    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

    Path to the worker file.

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

    Number of workers that this pool should manage.

    -
    +
  • Defined in src/pools/abstract-pool.ts:127
  • - -
    opts: PoolOptions<ThreadWorkerWithMessageChannel>
    -

    Options for the pool.

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

    When we receive a message from the worker, we get a map entry with the promise resolve/reject bound to the message id.

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

    -

    Default to a round robin algorithm.

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

    - +
    +
  • Defined in src/pools/thread/dynamic.ts:44
  • - +
    +
  • Defined in src/pools/abstract-pool.ts:651
  • - +
    -
    - -
    +
    + +
    +
  • Defined in src/pools/abstract-pool.ts:484
  • - +
    +
  • Defined in src/pools/abstract-pool.ts:477
  • +
    + +
    - +
    +
  • Defined in src/pools/thread/dynamic.ts:39
  • +
    + +
    - +
    +
  • Defined in src/pools/thread/fixed.ts:149
  • Methods

    +
    + +
    - + +

    Returns void

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

    Returns void

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

    Returns void

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

    Returns Promise<void>

    +
    +
  • Defined in src/pools/thread/fixed.ts:60
  • - + +

    Returns void

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

    Returns Promise<Response>

    Promise that will be fulfilled when the task is completed.

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

    Returns void

    -

    Returns void

    +
  • Defined in src/pools/thread/fixed.ts:106
  • +
    + +
    +
    + +
    +
    + +
    - + +

    Returns void

    +
    +
  • Defined in src/pools/thread/fixed.ts:77
  • +
    + +
    - + +

    Returns void

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

    Returns void

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

    Returns void

    +
  • Defined in src/pools/abstract-pool.ts:551
  • - +
    +
  • Defined in src/pools/abstract-pool.ts:989
  • +
    + +
    - +
    +
  • Defined in src/pools/abstract-pool.ts:1497
  • -

    On This Page

    +

    On This Page

    +
  • constructor
  • +
  • emitter
  • +
  • filePath
  • +
  • max
  • +
  • numberOfWorkers
  • +
  • opts
  • +
  • promiseResponseMap
  • +
  • workerChoiceStrategyContext
  • +
  • workerNodes
  • +
  • busy
  • +
  • full
  • +
  • info
  • +
  • maxSize
  • +
  • minSize
  • +
  • ready
  • +
  • type
  • +
  • utilization
  • +
  • worker
  • +
  • addTaskFunction
  • +
  • afterTaskExecutionHook
  • +
  • afterWorkerNodeSetup
  • +
  • beforeTaskExecutionHook
  • +
  • createAndSetupDynamicWorkerNode
  • +
  • createAndSetupWorkerNode
  • +
  • createWorker
  • +
  • deregisterWorkerMessageListener
  • +
  • destroy
  • +
  • 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