X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedClusterPool.html;h=b66a5d35120498c362f7c01bc547e59f82a6cbcd;hb=90ee1b18c5477c9caccc2c4015ecfaf84c40e39d;hp=7a604f5721b392d12a1bb0cbd45c659153579df4;hpb=d0f1dce33156fdb99f0ca3627839001909419497;p=poolifier.git
diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html
index 7a604f57..b66a5d35 100644
--- a/docs/classes/FixedClusterPool.html
+++ b/docs/classes/FixedClusterPool.html
@@ -1,52 +1,695 @@
-
FixedClusterPool | poolifierClass FixedClusterPool<Data, Response>
+
+Protected
workerChoiceStrategyContext
+workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
+
+
+Readonly
workers
+workers: Worker[] = []
+
+
+Readonly
workersTasksUsage
+workersTasksUsage: Map<Worker, TasksUsage> = ...
+
+
+Accessors
+
+busy
+
+- get busy(): boolean
+-
+
+
Returns boolean
+
+numberOfRunningTasks
+
+- get numberOfRunningTasks(): number
+-
+
+
Returns number
+
+type
+
+- get type(): PoolType
+-
+
+
Returns PoolType
+
+Methods
+
+Protected
afterPromiseWorkerResponseHook
+
+- afterPromiseWorkerResponseHook(message: MessageValue<Response, unknown>, promise: PromiseWorkerResponseWrapper<Worker, Response>): void
+-
+
+
+
Parameters
+
+-
+
message: MessageValue<Response, unknown>
+
+-
+
promise: PromiseWorkerResponseWrapper<Worker, Response>
+
+Returns void
+
+Protected
afterWorkerSetup
+
+- afterWorkerSetup(worker: Worker): void
+-
+
+
+
Returns void
+
+Protected
beforePromiseWorkerResponseHook
+
+- beforePromiseWorkerResponseHook(worker: Worker): void
+-
+
+
+
Returns void
+
+Protected
chooseWorker
+
+- chooseWorker(): Worker
+-
+
+
Returns Worker
+
+Protected
createAndSetupWorker
+
+- createAndSetupWorker(): Worker
+-
+
+
Returns Worker
+
+Protected
createWorker
+
+- createWorker(): Worker
+-
+
+
Returns Worker
+
+destroy
+
+- destroy(): Promise<void>
+-
+
+
Returns Promise<void>
+
+destroyWorker
+
+- destroyWorker(worker: Worker): void
+-
+
+
+
Returns void
+
+execute
+
+- execute(data: Data): Promise<Response>
+-
+
+
+
Returns Promise<Response>
+
+findFreeWorker
+
+- findFreeWorker(): false | Worker
+-
+
+
Returns false | Worker
+
+getWorkerAverageTasksRunTime
+
+- getWorkerAverageTasksRunTime(worker: Worker): undefined | number
+-
+
+
+
Returns undefined | number
+
+getWorkerIndex
+
+- getWorkerIndex(worker: Worker): number
+-
+
+
+
Returns number
+
+getWorkerRunningTasks
+
+- getWorkerRunningTasks(worker: Worker): undefined | number
+-
+
+
+
Returns undefined | number
+
+initWorkerTasksUsage
+
+- initWorkerTasksUsage(worker: Worker): void
+-
+
+
+
Returns void
+
+Protected
internalExecute
+
+- internalExecute(worker: Worker, messageId: number): Promise<Response>
+-
+
+
Parameters
+
+-
+
worker: Worker
+-
+
messageId: number
+Returns Promise<Response>
+
+Protected
internalGetBusyStatus
+
+- internalGetBusyStatus(): boolean
+-
+
Returns boolean
+
+Protected
isMain
+
+- isMain(): boolean
+-
+
+
Returns boolean
+
+registerWorkerMessageListener
+
+- registerWorkerMessageListener<Message>(worker: Worker, listener: ((message: MessageValue<Message, unknown>) => void)): void
+-
+
+
+
+
Parameters
+
+-
+
worker: Worker
+-
+
listener: ((message: MessageValue<Message, unknown>) => void)
+
+-
+
+- (message: MessageValue<Message, unknown>): void
+-
+
+
Parameters
+
+-
+
message: MessageValue<Message, unknown>
+Returns void
+Returns void
+
+Protected
removeWorker
+
+- removeWorker(worker: Worker): void
+-
+
+
+
Returns void
+
+Protected
sendToWorker
+
+- sendToWorker(worker: Worker, message: MessageValue<Data, unknown>): void
+-
+
+
+
Parameters
+
+-
+
worker: Worker
+-
+
message: MessageValue<Data, unknown>
+Returns void
+
+setWorkerChoiceStrategy
+
+- setWorkerChoiceStrategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
+-
+
+
+
Parameters
+
+-
+
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
+Returns void
+
+Protected
setupHook
+
+- setupHook(): void
+-
+
+
Returns void
+
+Protected
workerListener
+
+- workerListener(): ((message: MessageValue<Response, unknown>) => void)
+-
+
+
Returns ((message: MessageValue<Response, unknown>) => void)
+
+-
+
+- (message: MessageValue<Response, unknown>): void
+-
+
+
+
Parameters
+
+-
+
message: MessageValue<Response, unknown>
+Returns void
+
+
+
\ No newline at end of file
A cluster pool with a fixed number of workers.
-It is possible to perform tasks in sync or asynchronous mode as you prefer.
++- Preparing search index...
+- The search index is not available
poolifier+- poolifier
+- FixedClusterPool
+Class FixedClusterPool<Data, Response>
A cluster pool with a fixed number of workers.
+It is possible to perform tasks in sync or asynchronous mode as you prefer.
This pool selects the workers in a round robin fashion.
-of data sent to the worker. This can only be serializable data.
-of response of execution. This can only be serializable data.
-Christopher Quadflieg
-2.0.0
-Type parameters
Data = unknown
Response = unknown
Hierarchy
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Constructs a new poolifier fixed cluster pool.
-Type parameters
Data = unknown
Response = unknown
Parameters
numberOfWorkers: number
Number of workers for this pool.
-filePath: string
Path to an implementation of a
-ClusterWorker
file, which can be relative or absolute.opts: ClusterPoolOptions = {}
Returns FixedClusterPool<Data, Response>
Properties
Optional Readonly emitter
Readonly file Path
Optional Readonly max
Protected next Message Id
Id of the next message.
-Readonly number Of Workers
Readonly opts
Protected promise Map
The promise map.
-+ +
Template
of data sent to the worker. This can only be serializable data.
+ +Template
of response of execution. This can only be serializable data.
+ +Author
Christopher Quadflieg
+ +Since
2.0.0
+Type Parameters
++-
+
+-
+
Data = unknown
Response = unknown
Hierarchy
++- AbstractPool<Worker, Data, Response>
+
+- FixedClusterPool
+
+- DynamicClusterPool
+
+Index
Constructors
+Properties
+Accessors
+Methods
+Constructors
+constructor
++- new
Fixed Cluster Pool<Data, Response>(numberOfWorkers: number, filePath: string, opts?: ClusterPoolOptions): FixedClusterPool<Data, Response>
+-
+
+
+
+
+
+
Constructs a new poolifier fixed cluster pool.
+Type Parameters
++-
+
+-
+
Data = unknown
Response = unknown
Parameters
++-
+
+-
+
+-
+
numberOfWorkers: number
+Number of workers for this pool.
+filePath: string
+Path to an implementation of a
+ClusterWorker
file, which can be relative or absolute.opts: ClusterPoolOptions = {}
+Options for this fixed cluster pool.
+Returns FixedClusterPool<Data, Response>
Properties
+
+Optional
Readonly
emitterInherit Doc
Path
+Readonly
file
+Optional
Readonly
maxInherit Doc
Message Id
+Protected
nextId of the next message.
+ Of Workers
+Readonly
number
+Readonly
opts Map
+Protected
promiseThe 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.When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.
-Readonly tasks
Protected worker Choice Strategy Context
Worker choice strategy instance implementing the worker choice algorithm.
-Default to a strategy implementing a round robin algorithm.
-Readonly workers
Accessors
busy
Returns boolean
number Of Running Tasks
Returns number
type
Returns PoolType
Methods
Protected after Worker Setup
Parameters
worker: Worker
Returns void
Protected choose Worker
Choose a worker for the next task.
-The default implementation uses a round robin algorithm to distribute the load.
-Returns Worker
Worker.
-Protected create And Setup Worker
Creates a new worker for this pool and sets it up completely.
-Returns Worker
New, completely set up worker.
-Protected create Worker
Returns Worker
Protected decrease Workers Tasks
Decrease the number of tasks that the given worker has applied.
-Parameters
worker: Worker
Worker whose tasks are decreased.
-Returns void
destroy
Returns Promise<void>
destroy Worker
Parameters
worker: Worker
Returns void
execute
Parameters
data: Data
Returns Promise<Response>
find Free Tasks Map Entry
Returns false | [Worker, number]
Protected increase Workers Task
Increase the number of tasks that the given worker has applied.
-Parameters
worker: Worker
Worker whose tasks are increased.
-Returns void
Protected internal Execute
Parameters
worker: Worker
messageId: number
Returns Promise<Response>
Protected internal Get Busy Status
Returns boolean
Protected is Main
Returns boolean
register Worker Message Listener
Type parameters
Message
Parameters
worker: Worker
listener: (message: MessageValue<Message, unknown>) => void
Parameters
message: MessageValue<Message, unknown>
Returns void
Returns void
Protected remove Worker
Removes the given worker from the pool.
-Parameters
worker: Worker
Worker that will be removed.
-Returns void
Protected send To Worker
Parameters
worker: Worker
message: MessageValue<Data, unknown>
Returns void
set Worker Choice Strategy
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"
Returns void
Protected setup Hook
Returns void
Protected worker Listener
This function is the listener registered for each worker.
-Returns (message: MessageValue<Response, unknown>) => void
The listener function to execute when a message is sent from a worker.
-This function is the listener registered for each worker.
-Parameters
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is sent from a worker.
-Generated using TypeDoc