X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=75da6d76187e524ab93943581bb7d79a573e2b97;hb=7cd8af0033b35def46016a78ea9be1ee516480bf;hp=6910150bf4dd6529111bb2ca763a2a2770729168;hpb=d0f1dce33156fdb99f0ca3627839001909419497;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 6910150b..75da6d76 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,57 +1,607 @@ -DynamicThreadPool | poolifier
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DynamicThreadPool<Data, Response>

-

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 DataType

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

-
template ResponseType

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

-
author

Alessandro Pio Ardizio

-
since

0.0.1

-

Type parameters

  • Data = unknown

  • Response = unknown

Hierarchy

Index

Constructors

constructor

Properties

Optional Readonly emitter

emitter?: PoolEmitter

Readonly filePath

filePath: string

Readonly max

max: number

Protected nextMessageId

nextMessageId: number = 0
-

Id of the next message.

-

Readonly numberOfWorkers

numberOfWorkers: number

Readonly opts

Protected promiseMap

promiseMap: Map<number, PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
-

The promise map.

-

Readonly tasks

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

Protected workerChoiceStrategyContext

workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
-

Worker choice strategy instance implementing the worker choice algorithm.

-

Default to a strategy implementing a round robin algorithm.

-

Readonly workers

Accessors

busy

  • get busy(): boolean

numberOfRunningTasks

  • get numberOfRunningTasks(): number

type

  • get type(): PoolType

Methods

Protected afterWorkerSetup

Protected chooseWorker

Protected createAndSetupWorker

Protected createWorker

Protected decreaseWorkersTasks

destroy

  • destroy(): Promise<void>

destroyWorker

execute

  • execute(data: Data): Promise<Response>

findFreeTasksMapEntry

Protected increaseWorkersTask

Protected internalExecute

Protected internalGetBusyStatus

  • internalGetBusyStatus(): boolean

Protected isMain

  • isMain(): boolean

registerWorkerMessageListener

  • registerWorkerMessageListener<Message>(messageChannel: ThreadWorkerWithMessageChannel, listener: (message: MessageValue<Message, unknown>) => void): void

Protected removeWorker

Protected sendToWorker

setWorkerChoiceStrategy

  • setWorkerChoiceStrategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"): void

Protected setupHook

  • setupHook(): void

Protected workerListener

  • workerListener(): (message: MessageValue<Response, unknown>) => void
  • -

    This function is the listener registered for each worker.

    -

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

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

    -
      • (message: MessageValue<Response, unknown>): void
      • -

        This function is the listener registered for each worker.

        -

        Parameters

        • message: MessageValue<Response, unknown>

        Returns void

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

        -

Generated using TypeDoc

\ No newline at end of file +

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

+ +
+ +
workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
+

Worker choice strategy context referencing a worker choice algorithm implementation.

+

Default to a round robin algorithm.

+
+
+ +
workers: WorkerType<ThreadWorkerWithMessageChannel>[] = []
+
+

Inherit Doc

+
+

Accessors

+
+ +
+
+ +
+
+ +
+
+ +
+
+

Methods

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+

Generated using TypeDoc

+
\ No newline at end of file