X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=e00359ef25599e5a990548d5d98ce960aa0d9b24;hb=94ab998f44abe7ed2184a0702c45621b06f5641f;hp=b7fba0c61ae31aaa5d6a377084a30609ae4b1385;hpb=248bc34b348a7d8d2b90eecff49d60a3b465da9e;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index b7fba0c6..e00359ef 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,11 +1,13 @@ DynamicThreadPool | poolifier
-
+
@@ -16,11 +18,7 @@

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, an event is emitted. If you want to listen to this event, use the pool's emitter.

- -

Template

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

- -

Template

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

+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

@@ -30,9 +28,13 @@ When the maximum number of threads is reached, an event is emitted. If you want

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 response of execution. This can only be serializable data.

+

Hierarchy

    @@ -40,7 +42,7 @@ When the maximum number of threads is reached, an event is emitted. If you want
    • DynamicThreadPool
+
  • Defined in src/pools/thread/dynamic.ts:17
  • @@ -54,37 +56,33 @@ When the maximum number of threads is reached, an event is emitted. If you want

    Properties

    Accessors

    Methods

    -
    afterWorkerSetup +
    afterPromiseResponseHook +afterWorkerSetup +beforePromiseResponseHook chooseWorker createAndSetupWorker createWorker -decreaseWorkersTasks destroy destroyWorker execute -findFreeWorker -getWorkerIndex -getWorkerRunningTasks -increaseWorkersTask -internalExecute -internalGetBusyStatus +findFreeWorkerKey +internalBusy isMain registerWorkerMessageListener removeWorker @@ -98,7 +96,7 @@ When the maximum number of threads is reached, an event is emitted. If you want

    Returns DynamicThreadPool<Data, Response>

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

    -
    emitter?: PoolEmitter
    +
    emitter?: PoolEmitter

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:32
  • -
    filePath: string
    -
    +
  • Defined in src/pools/abstract-pool.ts:67
  • +
    max: number
    -
    -

    Inherit Doc

    -
    - -
    nextMessageId: number = 0
    -

    Id of the next message.

    +

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

    +
  • Defined in src/pools/thread/dynamic.ts:31
  • -
    numberOfWorkers: number
    +
  • Defined in src/pools/abstract-pool.ts:66
  • -
    -
    - -
    promiseMap: Map<number, PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
    -

    The promise map.

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

    The promise response map.

      -
    • key: This is the message Id of each submitted task.
    • -
    • value: An object that contains the worker, the resolve function and the reject function.
    • +
    • key: The message id of each submitted task.
    • +
    • value: An object that contains the worker, the promise resolve and reject callbacks.
    -

    When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.

    +

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

    -
    - -
    tasks: Map<ThreadWorkerWithMessageChannel, number> = ...
    -
    -

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:42
  • workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    -

    Worker choice strategy instance implementing the worker choice algorithm.

    -

    Default to a strategy implementing a round robin algorithm.

    +

    Worker choice strategy context referencing a worker choice algorithm implementation.

    +

    Default to a round robin algorithm.

    +
  • Defined in src/pools/abstract-pool.ts:52
  • - +
    workers: WorkerType<ThreadWorkerWithMessageChannel>[] = []

    Inherit Doc

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

    @@ -226,18 +213,29 @@ When the maximum number of threads is reached, an event is emitted. If you want

    Returns boolean

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

      Number of tasks concurrently running in the pool.

      +

      Returns number

    +
  • Defined in src/pools/abstract-pool.ts:149
    • @@ -248,9 +246,32 @@ When the maximum number of threads is reached, an event is emitted. If you want

      Returns PoolType

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

    +
    + +
    +
  • Defined in src/pools/thread/fixed.ts:85
  • +
    + +
    +
  • Defined in src/pools/abstract-pool.ts:297
  • +
  • Defined in src/pools/abstract-pool.ts:363
  • -
    - -
    +
  • Defined in src/pools/thread/fixed.ts:78
  • +
  • Defined in src/pools/abstract-pool.ts:220
  • +
  • Defined in src/pools/thread/fixed.ts:54
  • -
    - -
    -
    - +
  • Defined in src/pools/abstract-pool.ts:204
  • +
    +
    -
    - -
    -
    - -
    -
    - -
    -
    - +
  • Defined in src/pools/abstract-pool.ts:197
  • +
    +
    +
  • Defined in src/pools/abstract-pool.ts:189
  • +
  • Defined in src/pools/thread/fixed.ts:49
  • +
  • Defined in src/pools/thread/fixed.ts:70
    • @@ -509,12 +465,12 @@ When the maximum number of threads is reached, an event is emitted. If you want

    Returns void

    +
  • Defined in src/pools/abstract-pool.ts:487
  • +
  • Defined in src/pools/thread/fixed.ts:62
    • - +
    • Inherit Doc

      @@ -544,23 +500,24 @@ When the maximum number of threads is reached, an event is emitted. If you want

      Parameters

      • -
        workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"
    +
    workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"

    Returns void

    +
  • Defined in src/pools/abstract-pool.ts:164
  • +
  • Defined in src/pools/abstract-pool.ts:242
  • +
  • Defined in src/pools/abstract-pool.ts:392