X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=66d9f45a8f6237d9b94258e27bce62d4bc7e8bd9;hb=6c7d45d0e98d9849cfa99fe8d0aa567c989d049f;hp=26289e94772a1f37b1abd17a9e09150e8bc9c459;hpb=3557031d88b5ff00ea86695728b3ba3af46e9faa;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 26289e94..66d9f45a 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,13 +1,13 @@ -
Optional
Readonly
emitter
Emitter on which events can be listened to.
+
+Optional
emitterEvent emitter integrated with async resource on which events can be listened to. +The async tracking tooling identifier is
poolifier:<PoolType>-<WorkerType>-pool
.Events that can currently be listened to:
-
-
+
+
+
+
'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.'busy'
: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing concurrently their tasks quota.'full'
: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.'destroy'
: Emitted when the pool is destroyed.'error'
: Emitted when an uncaught error occurs.'taskError'
: Emitted when an error occurs while executing a task.'backPressure'
: Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size >= maximum queue size).Protected
Readonly
fileProtected
Readonly
maxMaximum number of threads that can be created by this pool.
Protected
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.Protected
worker Nodes
+Readonly
workerReadonly
Internal
workerPool worker nodes.
Accessors
Protected
full@@ -258,7 +274,7 @@ When the maximum number of threads is reached and workers are busy, an event is
info
@@ -270,93 +286,118 @@ When the maximum number of threads is reached and workers are busy, an event is
Size
-Protected
max+- get maxSize(): number
-
-
- Defined in src/pools/abstract-pool.ts:484
Size
- get minSize(): number
-
-
- Defined in src/pools/abstract-pool.ts:477
- get ready(): boolean
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:429
- get type(): "fixed" | "dynamic"
-
-
+- Defined in src/pools/thread/dynamic.ts:39
- get utilization(): number
-
-
+- Defined in src/pools/abstract-pool.ts:446
Pool maximum size.
+The pool maximum size.
Returns number
+Protected
minPool minimum size.
+The pool minimum size.
Returns number
+Private
readyReturns boolean
-Private
starting-- get starting(): boolean
--
-
-
Returns boolean
Inherited from FixedThreadPool.starting
--- Defined in src/pools/abstract-pool.ts:405
Protected
typePool type.
+The pool type.
If it is
'dynamic'
, it provides themax
property.Returns "fixed" | "dynamic"
Overrides FixedThreadPool.type
-- Defined in src/pools/thread/dynamic.ts:38
Private
utilizationGets the approximate pool utilization.
+The approximate pool utilization.
Returns number
The pool utilization.
Inherited from FixedThreadPool.utilization
-- Defined in src/pools/abstract-pool.ts:425
Protected
worker-- get worker(): "cluster" | "thread"
+- get worker(): "thread" | "cluster"
-
-
-
+- Defined in src/pools/thread/fixed.ts:149
+
Task Execution Hook
Gets the worker type.
+The worker type.
Returns "cluster" | "thread"
+Returns "thread" | "cluster"
Inherited from FixedThreadPool.worker
-- Defined in src/pools/thread/fixed.ts:81
Methods
+add Task Function
++- add
Task Function(name, fn): Promise<boolean>
+-
+
+
+
+
+
+
Adds a task function to this pool. +If a task function with the same name already exists, it will be overwritten.
+Parameters
++-
+
+
+-
+
+
name: string
+The name of the task function.
+fn: TaskFunction<Data, Response>
+The task function.
+Returns Promise<boolean>
+ +true
if the task function was added,false
otherwise.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+fn
parameter is not a function.Inherited from FixedThreadPool.addTaskFunction
++- Defined in src/pools/abstract-pool.ts:796
Protected
after-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(workerNodeKey, message): void
-
-
-
-
@@ -378,28 +419,28 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:1033
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -365,8 +406,8 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
Inherited from FixedThreadPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:689
Worker Setup
+Protected
afterProtected
after-- after
Worker Setup(worker): void
+- after
Worker Node Setup(workerNodeKey): void
-
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:1344
Task Execution Hook
-
-- Defined in src/pools/abstract-pool.ts:1003
+
+ 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. +
Method hooked up after a worker node has been newly created. Can be overridden.
Parameters
worker: Worker
-The newly created worker.
+workerNodeKey: number
+The newly created worker node key.
Returns void
Inherited from FixedThreadPool.afterWorkerSetup
+Inherited from FixedThreadPool.afterWorkerNodeSetup
-- Defined in src/pools/abstract-pool.ts:924
Protected
before@@ -425,49 +466,33 @@ Can be overridden.
Inherited from FixedThreadPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:668
Dynamic Pool Size
+Protected
checkProtected
create-- check
Dynamic Pool Size(min, max): void
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-
-
Parameters
---
-
--
-
min: number
max: number
Returns void
Inherited from FixedThreadPool.checkDynamicPoolSize
--- Defined in src/pools/abstract-pool.ts:161
And Setup Dynamic Worker
-Protected
create-- create
And Setup Dynamic Worker(): Worker
--
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:1250
+
+ 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 Worker
New, completely set up dynamic worker.
+Returns number
New, completely set up dynamic worker node key.
Inherited from FixedThreadPool.createAndSetupDynamicWorker
+Inherited from FixedThreadPool.createAndSetupDynamicWorkerNode
-- Defined in src/pools/abstract-pool.ts:1007
And Setup Worker
+Protected
createProtected
create-- create
And Setup Worker(): Worker
+- create
And Setup Worker Node(): number
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:1206
Worker
+- Defined in src/pools/thread/fixed.ts:136
+
+
- destroy(): Promise<void>
-
-
-
-- Defined in src/pools/abstract-pool.ts:940
+
+ 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 Worker
New, completely set up worker.
+Returns number
New, completely set up worker node key.
Inherited from FixedThreadPool.createAndSetupWorker
+Inherited from FixedThreadPool.createAndSetupWorkerNode
-- Defined in src/pools/abstract-pool.ts:941
Protected
create@@ -480,68 +505,109 @@ Can be overridden.
Inherited from FixedThreadPool.createWorker
-- Defined in src/pools/thread/fixed.ts:68
Worker Message Listener
+Protected
deregister+- deregister
Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
+
Deregisters a listener callback on the worker given its worker node key.
+Type Parameters
++-
+
Message
Parameters
++-
+
+
+-
+
+
+
workerNodeKey: number
+The worker node key.
+listener: ((message) => void)
+The message listener callback.
++-
+
+- (message): void
+-
+
+
+
Parameters
++-
+
message: MessageValue<Message, unknown>
Returns void
Returns void
+Inherited from FixedThreadPool.deregisterWorkerMessageListener
++- Defined in src/pools/thread/fixed.ts:126
destroy
Terminates every current worker in this pool.
+Terminates all workers in this pool.
Returns Promise<void>
Inherited from FixedThreadPool.destroy
-- Defined in src/pools/abstract-pool.ts:623
Worker
+Protected
destroyProtected
destroy-- destroy
Worker(worker): Promise<void>
+- destroy
Worker Node(workerNodeKey): Promise<void>
-
-
-
-
-
+- Defined in src/pools/thread/fixed.ts:60
- enable
Tasks Queue(enable, tasksQueueOptions?): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:565
Terminates the given worker.
+Terminates the worker node given its worker node key.
Parameters
worker: Worker
-A worker within
+workerNodes
.workerNodeKey: number
+The worker node key.
Returns Promise<void>
Inherited from FixedThreadPool.destroyWorker
+Inherited from FixedThreadPool.destroyWorkerNode
-- Defined in src/pools/thread/fixed.ts:57
enable Tasks Queue
Enables/disables the worker tasks queue in this pool.
+Enables/disables the worker node tasks queue in this pool.
Parameters
enable: boolean
-Whether to enable or disable the worker tasks queue.
+Whether to enable or disable the worker node tasks queue.
-Optional
tasksQueueOptions: TasksQueueOptionsThe worker tasks queue options.
+The worker node tasks queue options.
Returns void
Inherited from FixedThreadPool.enableTasksQueue
-- Defined in src/pools/abstract-pool.ts:528
execute
-- execute(data?, name?): Promise<Response>
+- execute(data?, name?, transferList?): Promise<Response>
-
@@ -550,12 +616,17 @@ Can be overridden.
-
-
+
+-
+
+- Defined in src/pools/abstract-pool.ts:870
+
+
+
+
+
+
+
+
Busy
- internal
Busy(): boolean
-
-
+- Defined in src/pools/abstract-pool.ts:667
Main
+- Defined in src/pools/thread/fixed.ts:55
+
+
+
+
+
+
+
+
+
+
+
+
To Worker
+
\ No newline at end of file
Executes the specified function in the worker constructor with the task data input parameter.
-Optional
data: DataThe task input data for the specified worker function. This can only be structured-cloneable data.
+The optional 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 optional name of the task function to execute. If not specified, the default task function will be executed.
+
+Optional
transferList: TransferListItem[]An optional array of transferable objects to transfer ownership of. Ownership of the transferred objects is given to the pool's worker_threads worker and they should not be used in the main thread afterwards.
Returns Promise<Response>
Promise that will be fulfilled when the task is completed.
@@ -563,20 +634,97 @@ Can be overridden.Inherited from FixedThreadPool.execute
-- Defined in src/pools/abstract-pool.ts:588
Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey): void
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Inherited from FixedThreadPool.flushTasksQueue
++- Defined in src/pools/abstract-pool.ts:1666
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.
+ +Inherited from FixedThreadPool.getWorkerInfo
++- Defined in src/pools/abstract-pool.ts:1582
has Task Function
++- has
Task Function(name): boolean
+-
+
+
+
+
+
Whether the specified task function exists in this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns boolean
+ +true
if the task function exists,false
otherwise.Inherited from FixedThreadPool.hasTaskFunction
++- Defined in src/pools/abstract-pool.ts:783
has Worker Node Back Pressure
++- has
Worker Node Back Pressure(workerNodeKey): boolean
+
+
+
+
+
Internal
+Whether the worker node has back pressure (i.e. its tasks queue is full).
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns boolean
+ +true
if the worker node has back pressure,false
otherwise.Inherited from FixedThreadPool.hasWorkerNodeBackPressure
++- Defined in src/pools/abstract-pool.ts:1624
Protected
internalWhether worker nodes are executing at least one task.
+Whether worker nodes are executing concurrently their tasks quota or not.
Returns boolean
Worker nodes busyness boolean status.
Inherited from FixedThreadPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:579
Protected
is@@ -588,52 +736,228 @@ Can be overridden.
Inherited from FixedThreadPool.isMain
-- Defined in src/pools/thread/fixed.ts:52
list Task Function Names
++- list
Task Function Names(): string[]
+-
+
+
+
Lists the names of task function available in this pool.
+Returns string[]
The names of task function available in this pool.
+ +Inherited from FixedThreadPool.listTaskFunctionNames
++- Defined in src/pools/abstract-pool.ts:835
Once Worker Message Listener
+Protected
register+- register
Once Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
+
Registers once a listener callback on the worker given its worker node key.
+Type Parameters
++-
+
Message
Parameters
++-
+
+
+-
+
+
+
workerNodeKey: number
+The worker node key.
+listener: ((message) => void)
+The message listener callback.
++-
+
+- (message): void
+-
+
+
+
Parameters
++-
+
message: MessageValue<Message, unknown>
Returns void
Returns void
+Inherited from FixedThreadPool.registerOnceWorkerMessageListener
++- Defined in src/pools/thread/fixed.ts:116
Worker Message Listener
+Protected
register+- register
Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
+
Registers a listener callback on the worker given its worker node key.
+Type Parameters
++-
+
Message
Parameters
++-
+
+
+-
+
+
+
workerNodeKey: number
+The worker node key.
+listener: ((message) => void)
+The message listener callback.
++-
+
+- (message): void
+-
+
+
+
Parameters
++-
+
message: MessageValue<Message, unknown>
Returns void
Returns void
+Inherited from FixedThreadPool.registerWorkerMessageListener
++- Defined in src/pools/thread/fixed.ts:106
remove Task Function
++- remove
Task Function(name): Promise<boolean>
+-
+
+
+
+
+
Removes a task function from this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns Promise<boolean>
+ +true
if the task function was removed,false
otherwise.Inherited from FixedThreadPool.removeTaskFunction
++- Defined in src/pools/abstract-pool.ts:819
Kill Message To Worker
+Protected
send+- send
Kill Message To Worker(workerNodeKey): Promise<void>
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns Promise<void>
Inherited from FixedThreadPool.sendKillMessageToWorker
++- Defined in src/pools/abstract-pool.ts:951
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
+Inherited from FixedThreadPool.sendStartupMessageToWorker
++- Defined in src/pools/thread/fixed.ts:91
Protected
send-- send
To Worker(worker, message): void
+- send
To Worker(workerNodeKey, message, transferList?): void
-
-
-
-
-
+
+-
+
+- Defined in src/pools/thread/fixed.ts:77
+
+
- set
Tasks Queue Options(tasksQueueOptions): void
-
-
-
+- Defined in src/pools/abstract-pool.ts:579
+- Defined in src/pools/abstract-pool.ts:532
+- Defined in src/pools/abstract-pool.ts:551
Hook
-
-
+
+
+
-
-
\ No newline at end of file
+
Sends a message to the given worker.
+Sends a message to worker given its worker node key.
Parameters
worker: Worker
-The worker which should receive the message.
+workerNodeKey: number
+The worker node key.
message: MessageValue<Data, unknown>
The message.
+Optional
transferList: TransferListItem[]The optional array of transferable objects.
+Returns void
Inherited from FixedThreadPool.sendToWorker
-- Defined in src/pools/thread/fixed.ts:63
set Default Task Function
++- set
Default Task Function(name): Promise<boolean>
+-
+
+
+
+
+
Sets the default task function in this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns Promise<boolean>
+ +true
if the default task function was set,false
otherwise.Inherited from FixedThreadPool.setDefaultTaskFunction
++- Defined in src/pools/abstract-pool.ts:848
set Tasks Queue Options
Sets the worker tasks queue options in this pool.
+Sets the worker node tasks queue options in this pool.
Parameters
tasksQueueOptions: TasksQueueOptions
-The worker tasks queue options.
+The worker node tasks queue options.
Returns void
Inherited from FixedThreadPool.setTasksQueueOptions
-- Defined in src/pools/abstract-pool.ts:540
set Worker Choice Strategy
@@ -658,7 +982,7 @@ Can be overridden.
Inherited from FixedThreadPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:498
set Worker Choice Strategy Options
@@ -678,7 +1002,7 @@ Can be overridden.
Inherited from FixedThreadPool.setWorkerChoiceStrategyOptions
-- Defined in src/pools/abstract-pool.ts:517
Protected
setup@@ -691,40 +1015,41 @@ Can be overridden.
Inherited from FixedThreadPool.setupHook
-- Defined in src/pools/abstract-pool.ts:652
Listener
-Protected
worker-- worker
Listener(): ((message) => void)
+- Defined in src/pools/abstract-pool.ts:987
start
++- start(): void
-
-
-
+
+- start
+- worker
Message Listener
-
This function is the listener registered for each worker message.
+Starts the minimum number of workers in this pool.
Returns ((message) => void)
The listener function to execute when a message is received from a worker.
- ---
-
+-- (message): void
+
+
Returns void
+Inherited from FixedThreadPool.start
++- Defined in src/pools/abstract-pool.ts:924
Message Listener
+Protected
worker+- worker
Message Listener(message): void
-
-
-
-
-
+ - Defined in src/pools/abstract-pool.ts:1496
This function is the listener registered for each worker message.
+This method is the message listener registered on each worker.
Parameters
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is received from a worker.
- - +Returns void
Inherited from FixedThreadPool.workerListener
+Inherited from FixedThreadPool.workerMessageListener
-- Defined in src/pools/abstract-pool.ts:1038
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc