X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=ed6d4a8f3c416b5b31409288811c6536a70e6683;hb=a34454964733f585af19a04f21f9e35eb18c77b1;hp=1a2b41461599d0603fb24da6c2a1d7c4c18d1543;hpb=d61f24ac46792cfab91a154667f24fc57c90e66e;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 1a2b4146..ed6d4a8f 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,11 +1,13 @@
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'semitter
.Author
Alessandro Pio Ardizio
@@ -30,9 +28,13 @@ When the maximum number of threads is reached, an event is emitted. If you wantType 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
@@ -54,45 +56,45 @@ When the maximum number of threads is reached, an event is emitted. If you wantemitter?
file Path
-max
-next Message Id
+max
number Of Workers
opts
-promise Map
+promise Response Map
worker Choice Strategy Context
-workers
-workers Tasks Usage
+worker Nodes
Properties
Accessors
Methods
-Returns DynamicThreadPool<Data, Response>
Properties
-Optional
Readonly
emitterInherit Doc
Path
-Readonly
fileReadonly
maxInherit Doc
Inherited from FixedThreadPool.max
--- Defined in src/pools/thread/dynamic.ts:31
Message Id
-Protected
nextId of the next message.
+Maximum number of threads that can be created by this pool.
Inherited from FixedThreadPool.nextMessageId
-- Defined in src/pools/abstract-pool.ts:63
Of Workers
-Readonly
numberNumber of workers that this pool should manage.
+Inherited from FixedThreadPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:84
-Readonly
optsOptions for the pool.
+Inherited from FixedThreadPool.opts
-- Defined in src/pools/abstract-pool.ts:86
Map
-Protected
promiseThe promise map.
+ Response Map
+Protected
promiseThe 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.
Inherited from FixedThreadPool.promiseMap
+Inherited from FixedThreadPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:55
Protected
workerWorker 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.
Inherited from FixedThreadPool.workerChoiceStrategyContext
-- Defined in src/pools/abstract-pool.ts:70
-Readonly
workers Nodes
+Readonly
workerInherit Doc
Inherited from FixedThreadPool.workers
+Inherited from FixedThreadPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:33
Tasks Usage
-Readonly
workersInherit Doc
Inherited from FixedThreadPool.workersTasksUsage
--- Defined in src/pools/abstract-pool.ts:36
Accessors
Returns boolean
Overrides FixedThreadPool.busy
-- Defined in src/pools/thread/dynamic.ts:44
number Of Running Tasks
--- get numberOfRunningTasks(): number
+- Defined in src/pools/thread/dynamic.ts:49
full
++- get full(): boolean
-
+
+
Inherit Doc
Returns boolean
Overrides FixedThreadPool.full
++- Defined in src/pools/thread/dynamic.ts:44
Of Queued Tasks
+Private
number+- get numberOfQueuedTasks(): number
+-
+
+
+
Number of tasks queued in the pool.
+Returns number
Inherited from FixedThreadPool.numberOfQueuedTasks
++- Defined in src/pools/abstract-pool.ts:166
Of Running Tasks
+Private
number+- get numberOfRunningTasks(): number
+-
+
Number of tasks running in the pool.
+Returns number
Inherited from FixedThreadPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:156
type
@@ -250,13 +263,13 @@ When the maximum number of threads is reached, an event is emitted. If you want
Returns PoolType
Overrides FixedThreadPool.type
-- Defined in src/pools/thread/dynamic.ts:39
Methods
- Promise Worker Response Hook
+Protected
afterProtected
after-- after
Promise Worker Response Hook(message: MessageValue<Response, unknown>, promise: PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>): void
+- after
Promise Response Hook(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Response, unknown>): void
-
-
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:307
Worker Setup
-
-- Defined in src/pools/thread/fixed.ts:85
+
+ Promise Response Hook
-
-- Defined in src/pools/abstract-pool.ts:236
+
+
-
-
+
+
-
-
-- Defined in src/pools/abstract-pool.ts:563
+
+ Tasks Queue By Worker
+
+
Hook executed after the worker task promise resolution. Can be overridden.
@@ -265,17 +278,17 @@ Can be overridden.Parameters
message: MessageValue<Response, unknown>
-The received message.
+worker: ThreadWorkerWithMessageChannel
+The worker.
promise: PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>
-The Promise response.
+message: MessageValue<Response, unknown>
+The received message.
Returns void
Inherited from FixedThreadPool.afterPromiseWorkerResponseHook
+Inherited from FixedThreadPool.afterPromiseResponseHook
-- Defined in src/pools/abstract-pool.ts:263
Protected
after@@ -291,11 +304,11 @@ Can be overridden.
Returns void
Inherited from FixedThreadPool.afterWorkerSetup
-- Defined in src/pools/thread/fixed.ts:80
Promise Worker Response Hook
+Protected
beforeProtected
before-- before
Promise Worker Response Hook(worker: ThreadWorkerWithMessageChannel): void
+- before
Promise Response Hook(workerNodeKey: number): void
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:296
+
+ Worker Node
+
+
Hook executed before the worker task promise resolution. Can be overridden.
@@ -304,40 +317,40 @@ Can be overridden.Parameters
worker: ThreadWorkerWithMessageChannel
-The worker.
+workerNodeKey: number
+The worker node key.
Returns void
Inherited from FixedThreadPool.beforePromiseWorkerResponseHook
+Inherited from FixedThreadPool.beforePromiseResponseHook
-- Defined in src/pools/abstract-pool.ts:252
Worker
+Protected
chooseProtected
choose-- choose
Worker(): ThreadWorkerWithMessageChannel
+- choose
Worker Node(): [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
-
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:340
And Setup Worker
- create
And Setup Worker(): ThreadWorkerWithMessageChannel
-
-
+- Defined in src/pools/abstract-pool.ts:406
Worker
+- Defined in src/pools/thread/fixed.ts:78
+
+
+- Defined in src/pools/abstract-pool.ts:259
-
-
+
+
-
-
-
-
+
+
-
-- Defined in src/pools/abstract-pool.ts:551
+
+
-
-
Chooses a worker for the next task.
-The default implementation uses a round robin algorithm to distribute the load.
+Chooses a worker node for the next task.
+The default uses a round robin algorithm to distribute the load.
-Returns
Worker.
+Returns
[worker node key, worker node].
Returns ThreadWorkerWithMessageChannel
Inherited from FixedThreadPool.chooseWorker
+Returns [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
Inherited from FixedThreadPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:290
Protected
createCreates a new worker for this pool and sets it up completely.
+Creates a new worker and sets it up completely in the pool worker nodes.
Returns
New, completely set up worker.
Returns ThreadWorkerWithMessageChannel
Inherited from FixedThreadPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:344
Protected
create@@ -348,7 +361,21 @@ Can be overridden.
Returns ThreadWorkerWithMessageChannel
Inherited from FixedThreadPool.createWorker
-- Defined in src/pools/thread/fixed.ts:73
Task
+Protected
dequeue+- dequeue
Task(workerNodeKey: number): undefined | Task<Data>
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns undefined | Task<Data>
Inherited from FixedThreadPool.dequeueTask
++- Defined in src/pools/abstract-pool.ts:555
destroy
@@ -359,7 +386,7 @@ Can be overridden.
Returns Promise<void>
Inherited from FixedThreadPool.destroy
-- Defined in src/pools/abstract-pool.ts:222
destroy Worker
@@ -375,54 +402,27 @@ Can be overridden.
Returns Promise<void>
Inherited from FixedThreadPool.destroyWorker
-- Defined in src/pools/thread/fixed.ts:49
execute
--- execute(data: Data): Promise<Response>
+- Defined in src/pools/thread/fixed.ts:54
Task
+Protected
enqueue+- enqueue
Task(workerNodeKey: number, task: Task<Data>): void
-
-
-
-
-
-
-
Inherit Doc
Parameters
data: Data
Returns Promise<Response>
Inherited from FixedThreadPool.execute
--- Defined in src/pools/abstract-pool.ts:210
find Free Worker
--- find
Free Worker(): false | ThreadWorkerWithMessageChannel
--
-
-
-
-
Inherit Doc
Returns false | ThreadWorkerWithMessageChannel
Inherited from FixedThreadPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:199
get Worker Average Tasks Run Time
--- get
Worker Average Tasks Run Time(worker: ThreadWorkerWithMessageChannel): undefined | number
--
-
-
-
-
-
-
Inherit Doc
Parameters
-+-
-
workerNodeKey: number
worker: ThreadWorkerWithMessageChannel
Returns undefined | number
Inherited from FixedThreadPool.getWorkerAverageTasksRunTime
+task: Task<Data>
Returns void
Inherited from FixedThreadPool.enqueueTask
-- Defined in src/pools/abstract-pool.ts:171
get Worker Index
+execute
-- get
Worker Index(worker: ThreadWorkerWithMessageChannel): number
+- execute(data: Data): Promise<Response>
-
@@ -430,70 +430,59 @@ Can be overridden.
-
-
Inherit Doc
Parameters
worker: ThreadWorkerWithMessageChannel
Returns number
Inherited from FixedThreadPool.getWorkerIndex
+data: Data
Returns Promise<Response>
Inherited from FixedThreadPool.execute
-- Defined in src/pools/abstract-pool.ts:161
get Worker Running Tasks
+find Free Worker Node Key
-- get
Worker Running Tasks(worker: ThreadWorkerWithMessageChannel): undefined | number
+- find
Free Worker Node Key(): number
-
-
-
-
-
+
Inherit Doc
Parameters
---
-
worker: ThreadWorkerWithMessageChannel
Returns undefined | number
Inherited from FixedThreadPool.getWorkerRunningTasks
+Returns number
Inherited from FixedThreadPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:166
init Worker Tasks Usage
--- init
Worker Tasks Usage(worker: ThreadWorkerWithMessageChannel): void
+- Defined in src/pools/abstract-pool.ts:229
Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey: number): void
-
-
-
-
+
Initializes tasks usage statistics.
-Parameters
worker: ThreadWorkerWithMessageChannel
-The worker.
-workerNodeKey: number
Returns void
Inherited from FixedThreadPool.initWorkerTasksUsage
+Inherited from FixedThreadPool.flushTasksQueue
-- Defined in src/pools/abstract-pool.ts:470
Execute
+Protected
internalProtected
flush-- internal
Execute(worker: ThreadWorkerWithMessageChannel, messageId: number): Promise<Response>
+- flush
Tasks Queue By Worker(worker: ThreadWorkerWithMessageChannel): void
-
-
-
--
-
-
-
Parameters
worker: ThreadWorkerWithMessageChannel
messageId: number
Returns Promise<Response>
Inherited from FixedThreadPool.internalExecute
+worker: ThreadWorkerWithMessageChannel
Returns void
Inherited from FixedThreadPool.flushTasksQueueByWorker
-- Defined in src/pools/abstract-pool.ts:315
Get Busy Status
+Protected
internalProtected
internal-- internal
Get Busy Status(): boolean
+- internal
Busy(): boolean
-
-
Returns boolean
Inherited from FixedThreadPool.internalGetBusyStatus
+Inherited from FixedThreadPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:191
Protected
is@@ -504,7 +493,7 @@ Can be overridden.
Returns boolean
Inherited from FixedThreadPool.isMain
-- Defined in src/pools/thread/fixed.ts:44
register Worker Message Listener
@@ -538,25 +527,25 @@ Can be overridden.
Returns void
Inherited from FixedThreadPool.registerWorkerMessageListener
-- Defined in src/pools/thread/fixed.ts:65
Worker
+Protected
removeProtected
remove-- remove
Worker(worker: ThreadWorkerWithMessageChannel): void
+- remove
Worker Node(worker: ThreadWorkerWithMessageChannel): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:545
To Worker
+- Defined in src/pools/thread/fixed.ts:62
+
Removes the given worker from the pool.
+Removes the given worker from the pool worker nodes.
Parameters
worker: ThreadWorkerWithMessageChannel
-The worker that will be removed.
+The worker.
Returns void
Inherited from FixedThreadPool.removeWorker
+Inherited from FixedThreadPool.removeWorkerNode
-- Defined in src/pools/abstract-pool.ts:277
Protected
send@@ -574,11 +563,11 @@ Can be overridden.
Returns void
Inherited from FixedThreadPool.sendToWorker
-- Defined in src/pools/thread/fixed.ts:57
set Worker Choice Strategy
-- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
+- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
-
@@ -586,29 +575,43 @@ Can be overridden.
-
-
Inherit Doc
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
Returns void
Inherited from FixedThreadPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:176
Protected
setupSetup hook that can be overridden by a Poolifier pool implementation -to run code before workers are created in the abstract constructor.
+Setup hook to run code before worker node are created in the abstract constructor. +Can be overridden
Returns void
Inherited from FixedThreadPool.setupHook
-- Defined in src/pools/abstract-pool.ts:237
Queue Length
+Protected
tasks+- tasks
Queue Length(workerNodeKey: number): number
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns number
Inherited from FixedThreadPool.tasksQueueLength
++- Defined in src/pools/abstract-pool.ts:559
Protected
workerThis function is the listener registered for each worker.
+This function is the listener registered for each worker message.
Returns
The listener function to execute when a message is received from a worker.
This function is the listener registered for each worker.
+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 void
Inherited from FixedThreadPool.workerListener
-- Defined in src/pools/abstract-pool.ts:368
@@ -659,39 +662,39 @@ to run code before workers are created in the abstract constructor.- constructor
- emitter?
- file
Path
-- max
-- next
Message Id
+- max
- number
Of Workers
- opts
-- promise
Map
+- promise
Response Map
- worker
Choice Strategy Context
-- workers
-- workers
Tasks Usage
+- worker
Nodes
- busy
-- number
Of Running Tasks
+- full
+- number
Of Queued Tasks
+- number
Of Running Tasks
- type
-- after
Promise Worker Response Hook
+- after
Promise Response Hook
- after
Worker Setup
-- before
Promise Worker Response Hook
-- choose
Worker
+- before
Promise Response Hook
+- choose
Worker Node
- create
And Setup Worker
- create
Worker
+- dequeue
Task
- destroy
- destroy
Worker
+- enqueue
Task
- execute
-- find
Free Worker
-- get
Worker Average Tasks Run Time
-- get
Worker Index
-- get
Worker Running Tasks
-- init
Worker Tasks Usage
-- internal
Execute
-- internal
Get Busy Status
+- find
Free Worker Node Key
+- flush
Tasks Queue
+- flush
Tasks Queue By Worker
+- internal
Busy
- is
Main
- register
Worker Message Listener
-- remove
Worker
+- remove
Worker Node
- send
To Worker
- set
Worker Choice Strategy
- setup
Hook
+- tasks
Queue Length
- worker
Listener
Generated using TypeDoc