X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FDynamicThreadPool.html;h=2cc3a42b6aa0f3fc35fd7086e526338593e90f2f;hb=c97a785f1274883c88a77d2bf418ba6480d20d04;hp=a609d859bfb1757fb5c7beacb7dc657f3182dd43;hpb=6d59ea2c71b8a88d41498c6fb54dfad95fd3a3ac;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index a609d859..2cc3a42b 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,4 +1,4 @@ -
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.
@@ -73,24 +73,30 @@ When the maximum number of threads is reached and workers are busy, an event is info max Size
min Size
+ready
type
+utilization
worker
Methods
Properties
Emitter on which events can be listened to.
Events that can currently be listened to:
-
-
+
+
+
@@ -159,7 +166,7 @@ When the maximum number of threads is reached and workers are busy, an event is +'full'
: Emitted when the pool is dynamic and full.'busy'
: Emitted when the pool is busy.'full'
: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.'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 at least one task.'error'
: Emitted when an uncaught error occurs.'taskError'
: Emitted when an error occurs while executing a task.Protected
Readonly
fileProtected
Readonly
maxProtected
Readonly
numberProtected
Readonly
opts Response Map
-Protected
promiseThe execution response promise map.
+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. Choice Strategy Context
-Protected
workerWorker choice strategy context referencing a worker choice algorithm implementation.
Nodes
-Readonly
workerPool worker nodes.
Accessors
Protected
full@@ -254,7 +261,7 @@ When the maximum number of threads is reached and workers are busy, an event is
info
@@ -266,62 +273,87 @@ When the maximum number of threads is reached and workers are busy, an event is
Protected
maxPool maximum size.
+The pool maximum size.
Returns number
+Protected
minPool minimum size.
+The pool minimum size.
Returns number
+
+Private
ready+- get ready(): boolean
+-
+
+
The pool readiness boolean status.
+Returns boolean
+Protected
typePool type.
+The pool type.
If it is
'dynamic'
, it provides themax
property.Returns "fixed" | "dynamic"
+
+Private
utilization+- get utilization(): number
+-
+
+
The approximate pool utilization.
+Returns number
The pool utilization.
+ +Protected
worker-- get worker(): "cluster" | "thread"
+- get worker(): "thread" | "cluster"
-
-
-- Defined in src/pools/thread/fixed.ts:125
Task Execution Hook
Gets the worker type.
+The worker type.
Returns "cluster" | "thread"
+Returns "thread" | "cluster"
+Methods
Protected
after-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(workerNodeKey, message): void
-
-
-
-
-
@@ -343,28 +375,28 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:722
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -330,12 +362,12 @@ Can be overridden.Parameters
worker: ThreadWorkerWithMessageChannel
-The worker.
+workerNodeKey: number
+The worker node key.
message: MessageValue<Response, unknown, Worker | MessagePort>
+message: MessageValue<Response, unknown>
The received message.
Worker Setup
+Protected
afterProtected
after-- after
Worker Setup(worker): void
+- after
Worker Node Setup(workerNodeKey): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:951
Task Execution Hook
-
-- Defined in src/pools/abstract-pool.ts:701
+
+
+
+ And Setup Dynamic Worker Node
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.Method hooked up after a worker node has been newly created. +Can be overridden.
Parameters
worker: ThreadWorkerWithMessageChannel
-The newly created worker.
+workerNodeKey: number
+The newly created worker node key.
Returns void
Protected
before@@ -390,78 +422,94 @@ Can be overridden.
And Setup Dynamic Worker
+Protected
create Dynamic Pool Size
+Protected
check+- check
Dynamic Pool Size(min, max): void
+-
+
+
+
Parameters
++-
+
+-
+
min: number
max: number
Returns void
Protected
create-- create
And Setup Dynamic Worker(): ThreadWorkerWithMessageChannel
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-- Defined in src/pools/abstract-pool.ts:900
+
+ And Setup Worker Node
Creates a new dynamic worker and sets it up completely in the pool worker nodes.
+Creates a new, completely set up dynamic worker node.
Returns ThreadWorkerWithMessageChannel
New, completely set up dynamic worker.
+Returns number
New, completely set up dynamic worker node key.
- And Setup Worker
+Protected
createProtected
create-- create
And Setup Worker(): ThreadWorkerWithMessageChannel
+- create
And Setup Worker Node(): number
-
-
-- Defined in src/pools/abstract-pool.ts:860
Worker
+- Defined in src/pools/thread/fixed.ts:112
- destroy(): Promise<void>
-
-
-- Defined in src/pools/abstract-pool.ts:664
+
+ Worker Node
Creates a new worker and sets it up completely in the pool worker nodes.
+Creates a new, completely set up worker node.
Returns ThreadWorkerWithMessageChannel
New, completely set up worker.
+Returns number
New, completely set up worker node key.
+Protected
create-- create
Worker(): ThreadWorkerWithMessageChannel
+- create
Worker(): Worker
-
-
Creates a new worker.
Returns ThreadWorkerWithMessageChannel
Newly created worker.
+Returns Worker
Newly created worker.
destroy
Terminate every current worker in this pool.
+Terminates all workers in this pool.
Returns Promise<void>
- Worker
+Protected
destroyProtected
destroy-- destroy
Worker(worker): Promise<void>
+- destroy
Worker Node(workerNodeKey): Promise<void>
-
-
-
-
+- Defined in src/pools/thread/fixed.ts:59
+- Defined in src/pools/abstract-pool.ts:571
+- Defined in src/pools/thread/fixed.ts:102
+
+
To Worker
\ No newline at end of file
Terminates the given worker.
+Terminates the worker node given its worker node key.
Parameters
worker: ThreadWorkerWithMessageChannel
-A worker within
+workerNodes
.workerNodeKey: number
+The worker node key.
Returns Promise<void>
enable Tasks Queue
@@ -486,7 +534,7 @@ Can be overridden.
execute
@@ -499,12 +547,12 @@ Can be overridden.-
-
+- Defined in src/pools/abstract-pool.ts:632
+
+
+
+
Busy
+- Defined in src/pools/abstract-pool.ts:622
Main
+- Defined in src/pools/thread/fixed.ts:54
Worker Message Listener
-Optional
data: DataThe task input data for the specified worker function. This can only be serializable data.
+The task input data for the specified task function. This can only be structured-cloneable data.
-Optional
name: stringThe name of the worker function to execute. If not specified, the default worker function will be executed.
+The name of the task function to execute. If not specified, the default task function will be executed.
Returns Promise<Response>
Promise that will be fulfilled when the task is completed.
@@ -512,7 +560,42 @@ Can be overridden. Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey): void
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Worker Info
+Protected
get+- get
Worker Info(workerNodeKey): WorkerInfo
+-
+
+
+
+
Gets the worker information given its worker node key.
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns WorkerInfo
The worker information.
+ +Protected
internal@@ -525,7 +608,7 @@ Can be overridden.
Protected
is@@ -537,13 +620,13 @@ Can be overridden.
Protected
register-- register
Worker Message Listener<Message>(worker, listener): void
+- register
Worker Message Listener<Message>(workerNodeKey, listener): void
-
-
-
-
-
@@ -572,30 +655,50 @@ Can be overridden.
-
-
+
Registers a listener callback on the given worker.
+Registers a listener callback on the worker given its worker node key.
Type Parameters
@@ -554,8 +637,8 @@ Can be overridden.Parameters
worker: ThreadWorkerWithMessageChannel
-The worker which should register a listener.
+workerNodeKey: number
+The worker node key.
Parameters
message: MessageValue<Message, unknown, Worker | MessagePort>
message: MessageValue<Message, unknown>
Returns void
Returns void
Startup Message To Worker
+Protected
send+- send
Startup Message To Worker(workerNodeKey): void
+-
+
+
+
+
Sends the startup message to worker given its worker node key.
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns void
+Protected
send-- send
To Worker(worker, message): void
+- send
To Worker(workerNodeKey, message): void
-
-
-
-
-
-
@@ -603,7 +706,7 @@ Can be overridden.
+- Defined in src/pools/thread/fixed.ts:76
+- Defined in src/pools/abstract-pool.ts:583
+- Defined in src/pools/abstract-pool.ts:541
+- Defined in src/pools/abstract-pool.ts:560
Hook
- setup
Hook(): void
-
-
- Defined in src/pools/abstract-pool.ts:685
Listener
- worker
Listener(): ((message) => void)
-
-
- (message): void
-
-
-
-
+
+ - Defined in src/pools/abstract-pool.ts:1034
@@ -743,21 +846,27 @@ Can be overridden
- info
- max
Size
- min
Size
+- ready
- type
+- utilization
- worker
- after
Task Execution Hook
-- after
Worker Setup
+- after
Worker Node Setup
- before
Task Execution Hook
-- create
And Setup Dynamic Worker
-- create
And Setup Worker
+- check
Dynamic Pool Size
+- create
And Setup Dynamic Worker Node
+- create
And Setup Worker Node
- create
Worker
- destroy
-- destroy
Worker
+- destroy
Worker Node
- enable
Tasks Queue
- execute
+- flush
Tasks Queue
+- get
Worker Info
- internal
Busy
- is
Main
- register
Worker Message Listener
+- send
Startup Message To Worker
- send
To Worker
- set
Tasks Queue Options
- set
Worker Choice Strategy
@@ -765,7 +874,7 @@ Can be overridden
- setup
Hook
- worker
Listener
-
+- Worker
Types
+- available
Parallelism
Sends a message to the given worker.
+Sends a message to worker given its worker node key.
Parameters
worker: ThreadWorkerWithMessageChannel
-The worker which should receive the message.
+workerNodeKey: number
+The worker node key.
message: MessageValue<Data, unknown, Worker | MessagePort>
+message: MessageValue<Data, unknown>
The message.
set Tasks Queue Options
@@ -623,7 +726,7 @@ Can be overridden.
set Worker Choice Strategy
@@ -648,7 +751,7 @@ Can be overridden.
set Worker Choice Strategy Options
@@ -668,26 +771,26 @@ Can be overridden.
Protected
setupSetup hook to execute code before worker node are created in the abstract constructor. -Can be overridden
+Setup hook to execute code before worker nodes are created in the abstract constructor. +Can be overridden.
Returns void
+Protected
workerThis function is the listener registered for each worker message.
+This method is the listener registered for each worker message.
Returns ((message) => void)
The listener function to execute when a message is received from a worker.
@@ -696,20 +799,20 @@ Can be overriddenThis function is the listener registered for each worker message.
+This method is the listener registered for each worker message.
Parameters
message: MessageValue<Response, unknown, Worker | MessagePort>
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is received from a worker.
Generated using TypeDoc