X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FFixedThreadPool.html;h=7683c280d007b64b8048cc0c494cdd4143d66c03;hb=f9b4bbf801547d7e17bf43e2e586ac956e97e1b0;hp=da669dcdcbbea04958a44160ef7d38d7cfe7a397;hpb=6f0e7f0609e779dbf314d3f1a31660e7d369f591;p=poolifier.git diff --git a/docs/classes/FixedThreadPool.html b/docs/classes/FixedThreadPool.html index da669dcd..7683c280 100644 --- a/docs/classes/FixedThreadPool.html +++ b/docs/classes/FixedThreadPool.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
-- AbstractPool<ThreadWorkerWithMessageChannel, Data, Response>
+
- AbstractPool<ThreadWorkerWithMessageChannel, Data, Response>
- FixedThreadPool
- DynamicThreadPool
@@ -58,40 +58,35 @@emitter?
file Path
-next Message Id
number Of Workers
opts
-promise Map
+promise Response Map
worker Choice Strategy Context
-workers
-workers Tasks Usage
+worker Nodes
Properties
Accessors
-Methods
-constructor
-- new
Fixed Thread Pool<Data, Response>(numberOfThreads: number, filePath: string, opts?: PoolOptions<ThreadWorkerWithMessageChannel>): FixedThreadPool<Data, Response>
+- new
Fixed Thread Pool<Data, Response>(numberOfThreads: number, filePath: string, opts?: PoolOptions<ThreadWorkerWithMessageChannel>): FixedThreadPool<Data, Response>
-
@@ -128,362 +123,331 @@
Constructs a new poolifier fixed thread pool.
opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
Options for this fixed thread pool.
Returns FixedThreadPool<Data, Response>
Properties
Optional
Readonly
emitterInherit Doc
Inherited from AbstractPool.emitter
+Emitter on which events can be listened to.
+Events that can currently be listened to:
-- Defined in src/pools/abstract-pool.ts:40
+'full'
: Emitted when the pool is dynamic and full.'busy'
: Emitted when the pool is busy.Inherited from AbstractPool.emitter
++- Defined in src/pools/abstract-pool.ts:41
Path
-Readonly
fileInherited from AbstractPool.filePath
--- Defined in src/pools/abstract-pool.ts:80
Message Id
-Protected
nextId of the next message.
+Path to the worker-file.
Inherited from AbstractPool.nextMessageId
+Inherited from AbstractPool.filePath
-- Defined in src/pools/abstract-pool.ts:58
Of Workers
-Readonly
numberInherited from AbstractPool.numberOfWorkers
+Number of workers that this pool should manage.
+Inherited from AbstractPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:79
-Readonly
optsInherited from AbstractPool.opts
+Options for the pool.
+Inherited from AbstractPool.opts
-- Defined in src/pools/abstract-pool.ts:81
Map
-Protected
promiseThe promise map.
+ Response Map
+Protected
promiseThe execution response promise 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 execution response 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 id.
Inherited from AbstractPool.promiseMap
+Inherited from AbstractPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:50
Choice Strategy Context
-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 AbstractPool.workerChoiceStrategyContext
++- Defined in src/pools/abstract-pool.ts:61
Nodes
+Readonly
workerPool worker nodes.
Inherited from AbstractPool.workerChoiceStrategyContext
--- Defined in src/pools/abstract-pool.ts:65
-Readonly
workersInherit Doc
Inherited from AbstractPool.workers
--- Defined in src/pools/abstract-pool.ts:31
Tasks Usage
-Readonly
workersInherit Doc
Inherited from AbstractPool.workersTasksUsage
--- Defined in src/pools/abstract-pool.ts:34
Inherited from AbstractPool.workerNodes
++- Defined in src/pools/abstract-pool.ts:38
Accessors
-busy
-+
+- get busy(): boolean
-
-
-
+
-
-
+Protected
busyInherit Doc
Whether the pool is busy or not.
+The pool busyness boolean status.
+Returns boolean
Overrides AbstractPool.busy
-- Defined in src/pools/thread/fixed.ts:95
number Of Running Tasks
-+- 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
++- Defined in src/pools/thread/fixed.ts:100
Of Queued Tasks
+Private
number+- get numberOfQueuedTasks(): number
+-
+
+
+
Number of tasks queued in the pool.
+Returns number
Inherited from AbstractPool.numberOfQueuedTasks
++- Defined in src/pools/abstract-pool.ts:186
Of Running Tasks
+Private
numberInherit Doc
Number of tasks running in the pool.
+Returns number
Inherited from AbstractPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:151
type
-- get type(): PoolType
+- get type(): PoolType
-
-
-
-
+
+
Inherit Doc
Returns PoolType
Pool type.
+If it is
+'dynamic'
, it provides themax
property.Returns PoolType
Overrides AbstractPool.type
-- Defined in src/pools/thread/fixed.ts:90
Methods
- Promise Worker Response Hook
+Protected
afterProtected
after-- after
Promise Worker Response Hook(message: MessageValue<Response, unknown>, promise: PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>): void
+- after
Task Execution Hook(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Response, unknown>): void
-
-
-
-
-
-
-
+- 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
-
-
+- Defined in src/pools/thread/fixed.ts:70
To Worker
-
+- Defined in src/pools/thread/fixed.ts:62
-
Hook executed after the worker task promise resolution. +
Hook executed after the worker task execution. 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 AbstractPool.afterPromiseWorkerResponseHook
+Inherited from AbstractPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:260
Protected
afterInherit Doc
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
Overrides AbstractPool.afterWorkerSetup
+Overrides AbstractPool.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
Task Execution Hook(workerNodeKey: number): void
-
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:324
+
+ Worker Node
-
-- Defined in src/pools/abstract-pool.ts:256
+
+
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:249
+
+ Busy
+- Defined in src/pools/abstract-pool.ts:244
Main
- is
Main(): boolean
-
-
-
+
-
-
-
+
+
-
Hook executed before the worker task promise resolution. +
Hook executed before the worker task execution. Can be overridden.
Parameters
worker: ThreadWorkerWithMessageChannel
-The worker.
+workerNodeKey: number
+The worker node key.
Returns void
Inherited from AbstractPool.beforePromiseWorkerResponseHook
+Inherited from AbstractPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:249
Worker
+Protected
chooseProtected
choose-- choose
Worker(): 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
-
-
-
-
+
+
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 AbstractPool.chooseWorker
+Returns [number, WorkerNode<ThreadWorkerWithMessageChannel, Data>]
Inherited from AbstractPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:287
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 AbstractPool.createAndSetupWorker
+Inherited from AbstractPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:341
Protected
createInherit Doc
Returns a newly created worker.
+Returns ThreadWorkerWithMessageChannel
Overrides AbstractPool.createWorker
+Overrides AbstractPool.createWorker
-- Defined in src/pools/thread/fixed.ts:73
destroy
Inherit Doc
Shutdowns every current worker in this pool.
+Returns Promise<void>
Inherited from AbstractPool.destroy
+Inherited from AbstractPool.destroy
-- Defined in src/pools/abstract-pool.ts:219
destroy Worker
-+- Defined in src/pools/abstract-pool.ts:287
Worker
+Protected
destroyInherit Doc
Shutdowns the given worker.
+Parameters
worker: ThreadWorkerWithMessageChannel
worker: ThreadWorkerWithMessageChannel
+A worker within
+workerNodes
.Returns Promise<void>
Overrides AbstractPool.destroyWorker
+Overrides AbstractPool.destroyWorker
-- Defined in src/pools/thread/fixed.ts:49
execute
-- execute(data: Data): Promise<Response>
+- execute(data: Data): Promise<Response>
-
-
-
-
-
-
-
Inherit Doc
Parameters
---
-
data: Data
Returns Promise<Response>
Inherited from AbstractPool.execute
--- Defined in src/pools/abstract-pool.ts:205
find Free Worker
--- find
Free Worker(): false | ThreadWorkerWithMessageChannel
--
-
-
-
-
Inherit Doc
Returns false | ThreadWorkerWithMessageChannel
Inherited from AbstractPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:194
get Worker Average Tasks Run Time
--- get
Worker Average Tasks Run Time(worker: ThreadWorkerWithMessageChannel): undefined | number
--
-
-
+
-
-
-
-
Inherit Doc
Performs the task specified in the constructor with the data parameter.
+ +Returns
Promise that will be resolved when the task is successfully completed.
+Parameters
worker: ThreadWorkerWithMessageChannel
Returns undefined | number
Inherited from AbstractPool.getWorkerAverageTasksRunTime
+data: Data
+The input for the specified task. This can only be serializable data.
+Returns Promise<Response>
Inherited from AbstractPool.execute
-- Defined in src/pools/abstract-pool.ts:166
get Worker Index
+find Free Worker Node Key
-- get
Worker Index(worker: ThreadWorkerWithMessageChannel): number
+- find
Free Worker Node Key(): number
-
-
-
-
-
+
-
Inherit Doc
Parameters
---
-
worker: ThreadWorkerWithMessageChannel
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.getWorkerIndex
--- Defined in src/pools/abstract-pool.ts:156
get Worker Running Tasks
--- get
Worker Running Tasks(worker: ThreadWorkerWithMessageChannel): undefined | number
--
-
-
-
-
-
-
Inherit Doc
Parameters
---
-
worker: ThreadWorkerWithMessageChannel
Returns undefined | number
Inherited from AbstractPool.getWorkerRunningTasks
--- Defined in src/pools/abstract-pool.ts:161
Execute
-Protected
internal-- internal
Execute(worker: ThreadWorkerWithMessageChannel, messageId: number): Promise<Response>
--
-
-
-
-
Parameters
---
-
--
-
worker: ThreadWorkerWithMessageChannel
messageId: number
Returns Promise<Response>
Inherited from AbstractPool.internalExecute
+Inherited from AbstractPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:312
Get Busy Status
+Protected
internalProtected
internal-- internal
Get Busy Status(): boolean
+- internal
Busy(): boolean
-
-
Returns boolean
Inherited from AbstractPool.internalGetBusyStatus
+Inherited from AbstractPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:186
Protected
isInherit Doc
Should return whether the worker is the main worker or not.
+Returns boolean
Overrides AbstractPool.isMain
+Overrides AbstractPool.isMain
-- Defined in src/pools/thread/fixed.ts:44
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
-
-
-
+
-
-
-
Inherit Doc
Registers a listener callback on the given worker.
+Type Parameters
@@ -493,104 +457,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
Overrides AbstractPool.registerWorkerMessageListener
--- Defined in src/pools/thread/fixed.ts:65
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 AbstractPool.removeWorker
+Overrides AbstractPool.registerWorkerMessageListener
-- Defined in src/pools/abstract-pool.ts:274
Protected
send-- send
To Worker(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Data, unknown>): void
+- send
To Worker(worker: ThreadWorkerWithMessageChannel, message: MessageValue<Data, unknown>): void
-
-
-
+
-
-
+
-
-
+
Inherit Doc
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
Overrides AbstractPool.sendToWorker
+Overrides AbstractPool.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
-
-
-
+
-
-
+
Inherit Doc
Sets the worker choice strategy in this pool.
+Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "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 AbstractPool.setWorkerChoiceStrategy
+Inherited from AbstractPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:171
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 AbstractPool.setupHook
+Inherited from AbstractPool.setupHook
-- Defined in src/pools/abstract-pool.ts:234
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
-
-
@@ -598,15 +554,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 AbstractPool.workerListener
+Inherited from AbstractPool.workerListener
-- Defined in src/pools/abstract-pool.ts:365
-
+Settings
Settings
Member Visibility
Theme
Generated using TypeDoc