repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore: v2.6.29
[poolifier.git]
/
src
/
pools
/
worker-node.ts
diff --git
a/src/pools/worker-node.ts
b/src/pools/worker-node.ts
index 64880fcb9820c098e37fb103bd27b8563073833a..7667dd16a6b99c2994eaeda37866662b43f8d178 100644
(file)
--- a/
src/pools/worker-node.ts
+++ b/
src/pools/worker-node.ts
@@
-28,9
+28,9
@@
implements IWorkerNode<Worker, Data> {
public messageChannel?: MessageChannel
/** @inheritdoc */
public usage: WorkerUsage
public messageChannel?: MessageChannel
/** @inheritdoc */
public usage: WorkerUsage
- private readonly tasksUsage: Map<string, WorkerUsage>
+ private readonly task
Function
sUsage: Map<string, WorkerUsage>
private readonly tasksQueue: Queue<Task<Data>>
private readonly tasksQueue: Queue<Task<Data>>
- private readonly tasksQueueBackPressure
Max
Size: number
+ private readonly tasksQueueBackPressureSize: number
/**
* Constructs a new worker node.
/**
* Constructs a new worker node.
@@
-46,9
+46,9
@@
implements IWorkerNode<Worker, Data> {
this.messageChannel = new MessageChannel()
}
this.usage = this.initWorkerUsage()
this.messageChannel = new MessageChannel()
}
this.usage = this.initWorkerUsage()
- this.tasksUsage = new Map<string, WorkerUsage>()
+ this.task
Function
sUsage = new Map<string, WorkerUsage>()
this.tasksQueue = new Queue<Task<Data>>()
this.tasksQueue = new Queue<Task<Data>>()
- this.tasksQueueBackPressure
Max
Size = Math.pow(poolMaxSize, 2)
+ this.tasksQueueBackPressureSize = Math.pow(poolMaxSize, 2)
}
/** @inheritdoc */
}
/** @inheritdoc */
@@
-82,13
+82,13
@@
implements IWorkerNode<Worker, Data> {
/** @inheritdoc */
public hasBackPressure (): boolean {
/** @inheritdoc */
public hasBackPressure (): boolean {
- return this.tasksQueueSize() >= this.tasksQueueBackPressure
Max
Size
+ return this.tasksQueueSize() >= this.tasksQueueBackPressureSize
}
/** @inheritdoc */
public resetUsage (): void {
this.usage = this.initWorkerUsage()
}
/** @inheritdoc */
public resetUsage (): void {
this.usage = this.initWorkerUsage()
- this.tasksUsage.clear()
+ this.task
Function
sUsage.clear()
}
/** @inheritdoc */
}
/** @inheritdoc */
@@
-103,23
+103,27
@@
implements IWorkerNode<Worker, Data> {
}
/** @inheritdoc */
}
/** @inheritdoc */
- public getTaskWorkerUsage (name: string): WorkerUsage | undefined {
+ public getTask
Function
WorkerUsage (name: string): WorkerUsage | undefined {
if (!Array.isArray(this.info.taskFunctions)) {
throw new Error(
if (!Array.isArray(this.info.taskFunctions)) {
throw new Error(
- `Cannot get task worker usage for task function name '${name}' when task function names list is not yet defined`
+ `Cannot get task
function
worker usage for task function name '${name}' when task function names list is not yet defined`
)
}
if (
)
}
if (
- name === DEFAULT_TASK_NAME &&
Array.isArray(this.info.taskFunctions) &&
Array.isArray(this.info.taskFunctions) &&
- this.info.taskFunctions.length
> 1
+ this.info.taskFunctions.length
< 3
) {
) {
+ throw new Error(
+ `Cannot get task function worker usage for task function name '${name}' when task function names list has less than 3 elements`
+ )
+ }
+ if (name === DEFAULT_TASK_NAME) {
name = this.info.taskFunctions[1]
}
name = this.info.taskFunctions[1]
}
- if (!this.tasksUsage.has(name)) {
- this.task
sUsage.set(name, this.initTask
WorkerUsage(name))
+ if (!this.task
Function
sUsage.has(name)) {
+ this.task
FunctionsUsage.set(name, this.initTaskFunction
WorkerUsage(name))
}
}
- return this.tasksUsage.get(name)
+ return this.task
Function
sUsage.get(name)
}
private initWorkerInfo (worker: Worker, workerType: WorkerType): WorkerInfo {
}
private initWorkerInfo (worker: Worker, workerType: WorkerType): WorkerInfo {
@@
-167,7
+171,7
@@
implements IWorkerNode<Worker, Data> {
}
}
}
}
- private initTaskWorkerUsage (name: string): WorkerUsage {
+ private initTask
Function
WorkerUsage (name: string): WorkerUsage {
const getTaskQueueSize = (): number => {
let taskQueueSize = 0
for (const task of this.tasksQueue) {
const getTaskQueueSize = (): number => {
let taskQueueSize = 0
for (const task of this.tasksQueue) {