X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedThreadPool.html;h=c7d211d68f6016a1c3c32768bec4adf1f576cf00;hb=6c15ffb2e59f4b3eaa6aedf0eb27feb2150cfb40;hp=357fe5d09f1c8bdf75a698044475f0895602248e;hpb=3bd6a82e43e11294af91bbd19647944ac740169e;p=poolifier.git diff --git a/docs/classes/FixedThreadPool.html b/docs/classes/FixedThreadPool.html index 357fe5d0..c7d211d6 100644 --- a/docs/classes/FixedThreadPool.html +++ b/docs/classes/FixedThreadPool.html @@ -24,9 +24,9 @@
0.0.1
-Overrides AbstractPool.sendToWorker
Sets the worker tasks queue options in this pool.
The worker tasks queue options.
Inherited from AbstractPool.setTasksQueueOptions
Sets the worker choice strategy in this pool.
The worker choice strategy.
Optional
workerChoiceStrategyOptions: WorkerChoiceStrategyOptionsOptional
workerChoiceStrategyOptions: WorkerChoiceStrategyOptionsThe worker choice strategy options.
Inherited from AbstractPool.setWorkerChoiceStrategy
Sets the worker choice strategy options in this pool.
The worker choice strategy options.
Inherited from AbstractPool.setWorkerChoiceStrategyOptions
Protected
setupSetup hook to execute code before worker node are created in the abstract constructor. Can be overridden
@@ -595,35 +606,33 @@ Can be overriddenInherited from AbstractPool.setupHook
Protected
workerThis function is the listener registered for each worker message.
- -The listener function to execute when a message is received from a worker.
The listener function to execute when a message is received from a worker.
+This function is the listener registered for each worker message.
- -The listener function to execute when a message is received from a worker.
The listener function to execute when a message is received from a worker.
+Inherited from AbstractPool.workerListener
Generated using TypeDoc
Type of data sent to the worker. This can only be serializable data.
@@ -38,13 +38,13 @@Hierarchy
-- AbstractPool<ThreadWorkerWithMessageChannel, Data, Response>
+
- AbstractPool<ThreadWorkerWithMessageChannel, Data, Response>
- FixedThreadPool
-- DynamicThreadPool
@@ -57,9 +57,9 @@
emitter?
-file Path
-number Of Workers
-opts
+file Path
+number Of Workers
+opts
promise Response Map
worker Choice Strategy Context
worker Nodes
@@ -67,10 +67,12 @@
busy
-full
-number Of Queued Tasks
-number Of Running Tasks
-type
+full
+info
+max Size
+min Size
+type
+worker
Worker
enable Tasks Queue
execute
-find Free Worker Node Key
internal Busy
is Main
register Worker Message Listener
@@ -100,13 +101,13 @@
-
+
Properties
Accessors
Methods
@@ -84,7 +86,6 @@ destroyconstructor
-- new
Fixed Thread Pool<Data, Response>(numberOfThreads, filePath, opts?): FixedThreadPool<Data, Response>
+- new
Fixed Thread Pool<Data, Response>(numberOfThreads, filePath, opts?): FixedThreadPool<Data, Response>
-
-
+
Constructs a new poolifier fixed thread pool.
Type Parameters
-+-
-
@@ -123,55 +124,57 @@
-
-
Data = unknown
Path to an implementation of a
ThreadWorker
file, which can be relative or absolute.opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
+opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
Options for this fixed thread pool.
Returns FixedThreadPool<Data, Response>
Returns FixedThreadPool<Data, Response>
Overrides AbstractPool.constructor
-- Defined in src/pools/thread/fixed.ts:40
Properties
-Optional
Readonly
emitterEmitter 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.'error'
: Emitted when an uncaught error occurs.'taskError'
: Emitted when an error occurs while executing a task.Inherited from AbstractPool.emitter
-- Defined in src/pools/abstract-pool.ts:42
Path
-Readonly
file Path
+Protected
Readonly
filePath to the worker file.
Inherited from AbstractPool.filePath
-- Defined in src/pools/abstract-pool.ts:77
Of Workers
-Readonly
number Of Workers
+Protected
Readonly
numberNumber of workers that this pool should manage.
Inherited from AbstractPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:76
-Readonly
opts
+Protected
Readonly
optsOptions for the pool.
Inherited from AbstractPool.opts
-- Defined in src/pools/abstract-pool.ts:78
Response Map
-Protected
promiseThe execution response promise map.
key
: The message id of each submitted task.Inherited from AbstractPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:52
Choice Strategy Context
-Protected
workerWorker choice strategy context referencing a worker choice algorithm implementation.
Default to a round robin algorithm.
Inherited from AbstractPool.workerChoiceStrategyContext
-- Defined in src/pools/abstract-pool.ts:62
Nodes
-Readonly
workerPool worker nodes.
Inherited from AbstractPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:39
Accessors
Returns boolean
Overrides AbstractPool.busy
-- Defined in src/pools/thread/fixed.ts:105
-Protected
full+- get full(): boolean
-
-
Whether the pool is full or not.
The pool filling boolean status.
Returns boolean
Overrides AbstractPool.full
+Inherited from AbstractPool.full
-- Defined in src/pools/thread/fixed.ts:100
Of Queued Tasks
-Private
number-- get numberOfQueuedTasks(): number
+- Defined in src/pools/abstract-pool.ts:360
info
++- get info(): PoolInfo
+-
+
+
+
Pool information.
+Returns PoolInfo
Inherited from AbstractPool.info
++- Defined in src/pools/abstract-pool.ts:215
Size
+Protected
max+- get maxSize(): number
-
-
-
-
-
+
+
+- Defined in src/pools/abstract-pool.ts:325
Number of tasks queued in the pool.
+Pool maximum size.
Returns number
Inherited from AbstractPool.numberOfQueuedTasks
+Overrides AbstractPool.maxSize
-- Defined in src/pools/abstract-pool.ts:195
Of Running Tasks
-Private
number-- get numberOfRunningTasks(): number
+- Defined in src/pools/thread/fixed.ts:115
Size
+Protected
min+- get minSize(): number
-
-
-
-
-
+
+
+- Defined in src/pools/thread/fixed.ts:100
+
+
Task Execution Hook
+- Defined in src/pools/abstract-pool.ts:464
Worker Setup
+- Defined in src/pools/thread/fixed.ts:90
Task Execution Hook
+- Defined in src/pools/thread/fixed.ts:59
Number of tasks running in the pool.
+Pool minimum size.
Returns number
Inherited from AbstractPool.numberOfRunningTasks
+Overrides AbstractPool.minSize
-- Defined in src/pools/abstract-pool.ts:185
type
--- get type(): PoolType
+- Defined in src/pools/thread/fixed.ts:110
+Protected
type+- get type(): "fixed" | "dynamic"
-
-
+
Pool type.
If it is
'dynamic'
, it provides themax
property.Returns PoolType
Returns "fixed" | "dynamic"
Overrides AbstractPool.type
-- Defined in src/pools/thread/fixed.ts:95
+Protected
worker+- get worker(): "cluster" | "thread"
+-
+
+
+
Gets the worker type.
+Returns "cluster" | "thread"
Overrides AbstractPool.worker
++- Defined in src/pools/thread/fixed.ts:105
Methods
Protected
after-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(worker, message): void
-
-
-
-
-
Hook executed after the worker task execution. Can be overridden.
@@ -273,21 +298,21 @@ Can be overridden.Parameters
worker: ThreadWorkerWithMessageChannel
+worker: ThreadWorkerWithMessageChannel
The worker.
message: MessageValue<Response, unknown>
+message: MessageValue<Response, Worker | MessagePort>
The received message.
Returns void
Inherited from AbstractPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:389
Protected
after-- after
Worker Setup(worker): void
+- after
Worker Setup(worker): void
-
-
-
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
@@ -296,17 +321,17 @@ Can be overridden.maxListeners
or binding themain-worker
<->worker
connection if not bind by default.Parameters
worker: ThreadWorkerWithMessageChannel
+worker: ThreadWorkerWithMessageChannel
The newly created worker.
Returns void
Overrides AbstractPool.afterWorkerSetup
-- Defined in src/pools/thread/fixed.ts:85
Protected
before-- before
Task Execution Hook(workerNodeKey): void
+- before
Task Execution Hook(workerNodeKey): void
-
+- Defined in src/pools/abstract-pool.ts:453
Worker Node
+- Defined in src/pools/abstract-pool.ts:532
And Setup Worker
+- Defined in src/pools/abstract-pool.ts:596
Worker
+- Defined in src/pools/thread/fixed.ts:83
+- Defined in src/pools/abstract-pool.ts:415
Worker
Hook executed before the worker task execution. Can be overridden.
@@ -321,60 +346,58 @@ Can be overridden.Returns void
Inherited from AbstractPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:378
Protected
choose-- choose
Worker Node(): [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
+- choose
Worker Node(): number
-
-
+
Chooses a worker node for the next task.
-The default uses a round robin algorithm to distribute the load.
- -Returns
[worker node key, worker node].
+The default worker choice strategy uses a round robin algorithm to distribute the load.
Returns [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
Returns number
The worker node key
+Inherited from AbstractPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:422
Protected
create-- create
And Setup Worker(): ThreadWorkerWithMessageChannel
+- create
And Setup Worker(): ThreadWorkerWithMessageChannel
-
-
+
Creates a new worker and sets it up completely in the pool worker nodes.
- -Returns
New, completely set up worker.
Returns ThreadWorkerWithMessageChannel
Returns ThreadWorkerWithMessageChannel
New, completely set up worker.
+Inherited from AbstractPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:484
Protected
create-- create
Worker(): ThreadWorkerWithMessageChannel
+- create
Worker(): ThreadWorkerWithMessageChannel
-
-
+
Returns a newly created worker.
Returns ThreadWorkerWithMessageChannel
Returns ThreadWorkerWithMessageChannel
Overrides AbstractPool.createWorker
-- Defined in src/pools/thread/fixed.ts:78
destroy
-- destroy(): Promise<void>
+- destroy(): Promise<void>
-
Shutdowns every current worker in this pool.
Returns Promise<void>
Inherited from AbstractPool.destroy
-- Defined in src/pools/abstract-pool.ts:341
Protected
destroy-- destroy
Worker(worker): Promise<void>
+- destroy
Worker(worker): Promise<void>
-
@@ -382,17 +405,17 @@ Can be overridden.
-
-
Shutdowns the given worker.
Parameters
worker: ThreadWorkerWithMessageChannel
+worker: ThreadWorkerWithMessageChannel
A worker within
workerNodes
.Returns Promise<void>
Overrides AbstractPool.destroyWorker
-- Defined in src/pools/thread/fixed.ts:54
enable Tasks Queue
-- enable
Tasks Queue(enable, tasksQueueOptions?): void
+- enable
Tasks Queue(enable, tasksQueueOptions?): void
-
@@ -404,21 +427,19 @@ Can be overridden.
-
-
Enables/disables the worker tasks queue in this pool.
Whether to enable or disable the worker tasks queue.
+Optional
tasksQueueOptions: TasksQueueOptionsOptional
tasksQueueOptions: TasksQueueOptionsThe worker tasks queue options.
Returns void
Inherited from AbstractPool.enableTasksQueue
-- Defined in src/pools/abstract-pool.ts:254
execute
-- execute(data?): Promise<Response>
+- execute(data?, name?): Promise<Response>
-
-
-
+-
+
-
+
-
-
+- Defined in src/pools/abstract-pool.ts:380
Busy
+- Defined in src/pools/abstract-pool.ts:371
Main
+- Defined in src/pools/thread/fixed.ts:54
Worker Message Listener
Executes the function specified in the worker constructor with the task data input parameter.
- -Returns
Promise that will be fulfilled when the task is completed.
+Executes the specified function in the worker constructor with the task data input parameter.
Parameters
@@ -426,63 +447,53 @@ Can be overridden.Optional
data: DataThe task input data for the specified worker function. This can only be serializable data.
+
+Optional
name: stringThe name of the worker function to execute. If not specified, the default worker function will be executed.
Returns Promise<Response>
Returns Promise<Response>
Promise that will be fulfilled when the task is completed.
+Inherited from AbstractPool.execute
-- Defined in src/pools/abstract-pool.ts:310
find Free Worker Node Key
--- find
Free Worker Node Key(): number
--
-
-
-
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 AbstractPool.findFreeWorkerNodeKey
--- Defined in src/pools/abstract-pool.ts:303
Protected
internal-- internal
Busy(): boolean
+- internal
Busy(): boolean
-
Returns boolean
Inherited from AbstractPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:298
Protected
is-- is
Main(): boolean
+- is
Main(): boolean
-
Should return whether the worker is the main worker or not.
Returns boolean
Overrides AbstractPool.isMain
-- Defined in src/pools/thread/fixed.ts:49
Protected
register-- register
Worker Message Listener<Message>(worker, listener): void
+- register
Worker Message Listener<Message>(worker, listener): void
-
-
+
-
-
-
@@ -498,16 +509,16 @@ Can be overridden.
-
-
+
Registers a listener callback on the given worker.
Type Parameters
-+-
Message
Parameters
worker: ThreadWorkerWithMessageChannel
+worker: ThreadWorkerWithMessageChannel
The worker which should register a listener.
Parameters
message: MessageValue<Message, unknown>
message: MessageValue<Message, Worker | MessagePort>
Returns void
Returns void
Overrides AbstractPool.registerWorkerMessageListener
-- Defined in src/pools/thread/fixed.ts:70
Protected
send-- send
To Worker(worker, message): void
+- send
To Worker(worker, message): void
-
@@ -515,21 +526,21 @@ Can be overridden.
-
-
-
-
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, Worker | MessagePort>
The message.