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.31
[poolifier.git]
/
src
/
pools
/
worker-node.ts
diff --git
a/src/pools/worker-node.ts
b/src/pools/worker-node.ts
index 09e4a7b5cd8831360365a7a88e338e3b921eaf91..82e276886c08f56bc4051bc537df88b222600af0 100644
(file)
--- a/
src/pools/worker-node.ts
+++ b/
src/pools/worker-node.ts
@@
-41,19
+41,21
@@
implements IWorkerNode<Worker, Data> {
*/
constructor (worker: Worker, workerType: WorkerType, poolMaxSize: number) {
if (worker == null) {
*/
constructor (worker: Worker, workerType: WorkerType, poolMaxSize: number) {
if (worker == null) {
- throw new Error('Cannot construct a worker node without a worker')
+ throw new
Type
Error('Cannot construct a worker node without a worker')
}
if (workerType == null) {
}
if (workerType == null) {
- throw new Error('Cannot construct a worker node without a worker type')
+ throw new TypeError(
+ 'Cannot construct a worker node without a worker type'
+ )
}
if (poolMaxSize == null) {
}
if (poolMaxSize == null) {
- throw new Error(
+ throw new
Type
Error(
'Cannot construct a worker node without a pool maximum size'
)
}
'Cannot construct a worker node without a pool maximum size'
)
}
- if (
isNaN
(poolMaxSize)) {
- throw new Error(
- 'Cannot construct a worker node with a
NaN pool maximum size
'
+ if (
!Number.isSafeInteger
(poolMaxSize)) {
+ throw new
Type
Error(
+ 'Cannot construct a worker node with a
pool maximum size that is not an integer
'
)
}
this.worker = worker
)
}
this.worker = worker
@@
-188,21
+190,25
@@
implements IWorkerNode<Worker, Data> {
}
private initTaskFunctionWorkerUsage (name: string): WorkerUsage {
}
private initTaskFunctionWorkerUsage (name: string): WorkerUsage {
- const getTaskQueueSize = (): number => {
- let taskQueueSize = 0
+ const getTask
Function
QueueSize = (): number => {
+ let task
Function
QueueSize = 0
for (const task of this.tasksQueue) {
for (const task of this.tasksQueue) {
- if (task.name === name) {
- ++taskQueueSize
+ if (
+ (task.name === DEFAULT_TASK_NAME &&
+ name === (this.info.taskFunctions as string[])[1]) ||
+ (task.name !== DEFAULT_TASK_NAME && name === task.name)
+ ) {
+ ++taskFunctionQueueSize
}
}
}
}
- return taskQueueSize
+ return task
Function
QueueSize
}
return {
tasks: {
executed: 0,
executing: 0,
get queued (): number {
}
return {
tasks: {
executed: 0,
executing: 0,
get queued (): number {
- return getTaskQueueSize()
+ return getTask
Function
QueueSize()
},
failed: 0
},
},
failed: 0
},