X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=02e1b442e92a7705258996de8b9e4622c676ec49;hb=e39450c0889208d6dcde666fc05b95fe7a98ee29;hp=9839ac139b1984a50c829efd4060c78d7cf895c8;hpb=e604957d6ec7c137a3588de2ebbc9c83c0f634ba;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 9839ac13..02e1b442 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,4 +1,4 @@ -
Type of response of execution. This can only be serializable data.
+Type of execution response. This can only be serializable data.
Hierarchy
-- FixedThreadPool<Data, Response>
+
- FixedThreadPool<Data, Response>
- DynamicThreadPool
@@ -56,36 +56,36 @@ When the maximum number of threads is reached and workers are busy, an event isemitter?
file Path
-max
+max
number Of Workers
opts
promise Response Map
worker Choice Strategy Context
-workers
+worker Nodes
Properties
Accessors
-Methods
-constructor
-- new
Dynamic Thread Pool<Data, Response>(min: number, max: number, filePath: string, opts?: PoolOptions<ThreadWorkerWithMessageChannel>): DynamicThreadPool<Data, Response>
+- new
Dynamic Thread Pool<Data, Response>(min: number, max: number, filePath: string, opts?: PoolOptions<ThreadWorkerWithMessageChannel>): DynamicThreadPool<Data, Response>
-
@@ -126,20 +126,25 @@ When the maximum number of threads is reached and workers are busy, an event is
Constructs a new poolifier dynamic thread pool.
opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
Options for this dynamic thread pool.
Returns DynamicThreadPool<Data, Response>
Properties
Optional
Readonly
emitter{@inheritDoc}
+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.Inherited from FixedThreadPool.emitter
-- Defined in src/pools/abstract-pool.ts:32
Readonly
fileInherited from FixedThreadPool.filePath
-- Defined in src/pools/abstract-pool.ts:67
+Private
Readonly
maxReadonly
maxMaximum number of threads that can be created by this pool.
-- Defined in src/pools/thread/dynamic.ts:31
Readonly
numberInherited from FixedThreadPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:66
Readonly
optsInherited from FixedThreadPool.opts
-- Defined in src/pools/abstract-pool.ts:68
Response Map
-Protected
promiseThe promise response map.
+The execution response promise map.
key
: The message id of each submitted task.value
: An object that contains the worker, the promise resolve and reject callbacks.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.
+When we receive a message from the worker, we get a map entry with the promise resolve/reject bound to the message id.
Inherited from FixedThreadPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:42
Choice Strategy Context
-Protected
workerWorker 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:52
-Readonly
workers{@inheritDoc}
+ Nodes
+Readonly
workerPool worker nodes.
Inherited from FixedThreadPool.workers
+Inherited from FixedThreadPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:29
Accessors
-busy
-+
+- get busy(): boolean
-
-
-
-
+
+- get full(): boolean
-
-
+- Defined in src/pools/thread/dynamic.ts:44
+
+
Of Running Tasks
- get numberOfRunningTasks(): number
-
-
+- Defined in src/pools/abstract-pool.ts:176
+Protected
busy{@inheritDoc}
+Whether the pool is busy or not.
+The pool busyness boolean status.
Returns boolean
Overrides FixedThreadPool.busy
-- Defined in src/pools/thread/dynamic.ts:49
full
-+- Defined in src/pools/thread/dynamic.ts:49
+Protected
full{@inheritDoc}
+Whether the pool is full or not.
+The pool filling boolean status.
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:186
Private
numberNumber of tasks concurrently running in the pool.
+Number of tasks running in the pool.
Returns number
Inherited from FixedThreadPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:163
type
-- get type(): PoolType
+- get type(): PoolType
-
-
-
+
+- Defined in src/pools/thread/dynamic.ts:39
-
+ Task Execution Hook
{@inheritDoc}
+Pool type.
+If it is
'dynamic'
, it provides themax
property.Returns PoolType
Returns PoolType
Overrides FixedThreadPool.type
-- Defined in src/pools/thread/dynamic.ts:39
Methods
- Promise Response Hook
+Protected
afterProtected
after-- after
Promise Response Hook(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Response, unknown>): void
+- after
Task Execution Hook(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Response, unknown>): void
-
-
@@ -265,140 +284,153 @@ Can be overridden.
-
-
-
+- Defined in src/pools/abstract-pool.ts:335
Worker Setup
- after
Worker Setup(worker: ThreadWorkerWithMessageChannel): void
-
-
-
-
+
-
-- Defined in src/pools/thread/fixed.ts:85
+
+ Task Execution Hook
Hook executed after the worker task promise resolution. +
Hook executed after the worker task execution. Can be overridden.
The worker.
message: MessageValue<Response, unknown>
+message: MessageValue<Response, unknown>
The received message.
Returns void
Inherited from FixedThreadPool.afterPromiseResponseHook
+Inherited from FixedThreadPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:278
Protected
after{@inheritDoc}
+Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes.
+Can be used to update the
maxListeners
or binding themain-worker
<->worker
connection if not bind by default.Parameters
worker: ThreadWorkerWithMessageChannel
worker: ThreadWorkerWithMessageChannel
+The newly created worker.
+Returns void
Inherited from FixedThreadPool.afterWorkerSetup
-- Defined in src/pools/thread/fixed.ts:85
Promise Response Hook
+Protected
beforeProtected
before-- before
Promise Response Hook(workerKey: number): void
+- before
Task Execution Hook(workerNodeKey: number): void
-
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:324
+
+ Worker Node
Hook executed before the worker task promise resolution. +
Hook executed before the worker task execution. Can be overridden.
Parameters
workerKey: number
-The worker key.
+workerNodeKey: number
+The worker node key.
Returns void
Inherited from FixedThreadPool.beforePromiseResponseHook
+Inherited from FixedThreadPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:267
Worker
+Protected
chooseProtected
choose-- choose
Worker(): [number, ThreadWorkerWithMessageChannel]
+- choose
Worker Node(): [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
-
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:368
And Setup Worker
- create
And Setup Worker(): ThreadWorkerWithMessageChannel
-
-
+- Defined in src/pools/abstract-pool.ts:430
Worker
- create
Worker(): ThreadWorkerWithMessageChannel
-
-
+- Defined in src/pools/thread/fixed.ts:78
- destroy(): Promise<void>
-
-
-
-
+
+- destroy
Worker(worker: ThreadWorkerWithMessageChannel): Promise<void>
-
-
-
-
+
+- Defined in src/pools/thread/fixed.ts:54
-
-- Defined in src/pools/abstract-pool.ts:256
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
Chooses a worker for the next task.
+Chooses a worker node for the next task.
The default uses a round robin algorithm to distribute the load.
-Returns
[worker key, worker].
+Returns
[worker node key, worker node].
Returns [number, ThreadWorkerWithMessageChannel]
Inherited from FixedThreadPool.chooseWorker
+Returns [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
Inherited from FixedThreadPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:307
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:352
Protected
create{@inheritDoc}
+Returns a newly created worker.
Returns ThreadWorkerWithMessageChannel
Inherited from FixedThreadPool.createWorker
-- Defined in src/pools/thread/fixed.ts:78
destroy
{@inheritDoc}
+Shutdowns every current worker in this pool.
Returns Promise<void>
Inherited from FixedThreadPool.destroy
-- Defined in src/pools/abstract-pool.ts:233
destroy Worker
-+- Defined in src/pools/abstract-pool.ts:287
Worker
+Protected
destroy{@inheritDoc}
+Shutdowns the given worker.
Parameters
worker: ThreadWorkerWithMessageChannel
worker: ThreadWorkerWithMessageChannel
+A worker within
+workerNodes
.Returns Promise<void>
Inherited from FixedThreadPool.destroyWorker
-- Defined in src/pools/thread/fixed.ts:54
execute
-- execute(data: Data): Promise<Response>
+- execute(data: Data): Promise<Response>
-
-
-
-
-
+
+
{@inheritDoc}
+Performs the task specified in the constructor with the data parameter.
+ +Returns
Promise that will be resolved when the task is successfully completed.
Parameters
data: Data
Returns Promise<Response>
data: Data
+The input for the specified task. This can only be serializable data.
+Returns Promise<Response>
Inherited from FixedThreadPool.execute
-- Defined in src/pools/abstract-pool.ts:217
find Free Worker Key
+find Free Worker Node Key
-- find
Free Worker Key(): number
+- find
Free Worker Node Key(): number
-
-
-
+- Defined in src/pools/abstract-pool.ts:249
Busy
+- Defined in src/pools/abstract-pool.ts:244
Main
- is
Main(): boolean
-
-
-
-
+
+
-
-
+- Defined in src/pools/thread/fixed.ts:70
To Worker
+- Defined in src/pools/thread/fixed.ts:62
- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
-
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:209
Hook
- setup
Hook(): void
-
-
+- Defined in src/pools/abstract-pool.ts:309
Listener
-
+- Defined in src/pools/abstract-pool.ts:453
+
+
-
-
-
+- constructor
+- emitter
+- file
Path
+- max
+- number
Of Workers
+- opts
+- promise
Response Map
+- worker
Choice Strategy Context
+- worker
Nodes
+- busy
+- full
+- number
Of Queued Tasks
+- number
Of Running Tasks
+- type
+- after
Task Execution Hook
+- after
Worker Setup
+- before
Task Execution Hook
+- choose
Worker Node
+- create
And Setup Worker
+- create
Worker
+- destroy
+- destroy
Worker
+- execute
+- find
Free Worker Node Key
+- internal
Busy
+- is
Main
+- register
Worker Message Listener
+- send
To Worker
+- set
Worker Choice Strategy
+- setup
Hook
+- worker
Listener
+
+
{@inheritDoc}
+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
Inherited from FixedThreadPool.findFreeWorkerKey
+Inherited from FixedThreadPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:210
Protected
internal@@ -407,24 +439,24 @@ Can be overridden.
Returns boolean
Inherited from FixedThreadPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:202
Protected
is{@inheritDoc}
+Should return whether the worker is the main worker or not.
Returns boolean
Inherited from FixedThreadPool.isMain
-- Defined in src/pools/thread/fixed.ts:49
register Worker Message Listener
--- register
Worker Message Listener<Message>(messageChannel: ThreadWorkerWithMessageChannel, listener: ((message: MessageValue<Message, unknown>) => void)): void
+- Defined in src/pools/thread/fixed.ts:49
Worker Message Listener
+Protected
register+- register
Worker Message Listener<Message>(messageChannel: ThreadWorkerWithMessageChannel, listener: ((message: MessageValue<Message, unknown>) => void)): void
-
-
-
-
+
-
-
-
{@inheritDoc}
+Registers a listener callback on the given worker.
Type Parameters
@@ -435,104 +467,96 @@ Can be overridden.Parameters
messageChannel: ThreadWorkerWithMessageChannel
messageChannel: ThreadWorkerWithMessageChannel
+The worker which should register a listener.
+listener: ((message: MessageValue<Message, unknown>) => void)
+listener: ((message: MessageValue<Message, unknown>) => void)
+The message listener callback.
+-- (message: MessageValue<Message, unknown>): void
+- (message: MessageValue<Message, unknown>): void
-
-
-
+
Parameters
message: MessageValue<Message, unknown>
message: MessageValue<Message, unknown>
Returns void
Returns void
Inherited from FixedThreadPool.registerWorkerMessageListener
-- Defined in src/pools/thread/fixed.ts:70
Worker
-Protected
remove-- remove
Worker(worker: ThreadWorkerWithMessageChannel): void
--
-
-
-
-
-
Removes the given worker from the pool.
-Parameters
---
-
worker: ThreadWorkerWithMessageChannel
-The worker that will be removed.
-Returns void
Inherited from FixedThreadPool.removeWorker
--- Defined in src/pools/abstract-pool.ts:475
Protected
send-- send
To Worker(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Data, unknown>): void
+- send
To Worker(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Data, unknown>): void
-
-
-
-
+
-
-
+
{@inheritDoc}
+Sends a message to the given worker.
Parameters
worker: ThreadWorkerWithMessageChannel
worker: ThreadWorkerWithMessageChannel
+The worker which should receive the message.
+message: MessageValue<Data, unknown>
message: MessageValue<Data, unknown>
+The message.
+Returns void
Inherited from FixedThreadPool.sendToWorker
-- Defined in src/pools/thread/fixed.ts:62
set Worker Choice Strategy
{@inheritDoc}
+Sets the worker choice strategy in this pool.
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
+The worker choice strategy.
+Returns void
Inherited from FixedThreadPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:178
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 execute 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:252
Protected
worker-- worker
Listener(): ((message: MessageValue<Response, unknown>) => void)
+- worker
Listener(): ((message: MessageValue<Response, unknown>) => void)
-
-
--
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 ((message: MessageValue<Response, unknown>) => void)
+Returns ((message: MessageValue<Response, unknown>) => void)
-- (message: MessageValue<Response, unknown>): void
+- (message: MessageValue<Response, unknown>): void
-
-
@@ -540,15 +564,16 @@ to run code before workers are created in the abstract constructor.
-
-
+
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.
Parameters
message: MessageValue<Response, unknown>
message: MessageValue<Response, unknown>
Returns void
Inherited from FixedThreadPool.workerListener
-- Defined in src/pools/abstract-pool.ts:381
-
+Settings
Settings
Member Visibility
Theme
Generated using TypeDoc