repositories
/
poolifier.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ccd3ada
)
Implement PR reviews
author
aardizio
<alessandroardizio94@gmail.com>
Mon, 15 Feb 2021 18:37:12 +0000
(19:37 +0100)
committer
aardizio
<alessandroardizio94@gmail.com>
Mon, 15 Feb 2021 18:37:12 +0000
(19:37 +0100)
CHANGELOG.md
patch
|
blob
|
blame
|
history
src/pools/abstract-pool.ts
patch
|
blob
|
blame
|
history
src/pools/cluster/dynamic.ts
patch
|
blob
|
blame
|
history
src/pools/thread/dynamic.ts
patch
|
blob
|
blame
|
history
diff --git
a/CHANGELOG.md
b/CHANGELOG.md
index 12fd3608b50babfda765bb43aceaad9a311a0b34..67a447c326a204331de30339025b3c4ce75ced09 100644
(file)
--- a/
CHANGELOG.md
+++ b/
CHANGELOG.md
@@
-8,7
+8,9
@@
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.0.0] - not released yet
### Bug fixes
## [2.0.0] - not released yet
### Bug fixes
- - Now a thread/process is not delete when the task submitted take more time than maxInactiveTime configured( issue #70)
+
+- Now a thread/process is not delete when the task submitted take more time than maxInactiveTime configured (issue #70)
+
### Breaking Changes
We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
### Breaking Changes
We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 879e3e4f78f2b3ab60a5918a865fa7c711e3d882..0685f998d4aaf11d0cb93d86fcdb24b0e3476fbc 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-190,23
+190,23
@@
export abstract class AbstractPool<
* @param worker Workers whose tasks are increased.
*/
protected increaseWorkersTask (worker: Worker): void {
* @param worker Workers whose tasks are increased.
*/
protected increaseWorkersTask (worker: Worker): void {
- const numberOfTasks
TheWorkerHa
s = this.tasks.get(worker)
- if (numberOfTasks
TheWorkerHa
s !== undefined) {
- this.tasks.set(worker, numberOfTasks
TheWorkerHa
s + 1)
+ const numberOfTasks
InProgres
s = this.tasks.get(worker)
+ if (numberOfTasks
InProgres
s !== undefined) {
+ this.tasks.set(worker, numberOfTasks
InProgres
s + 1)
} else {
throw Error('Worker could not be found in tasks map')
}
}
/**
} else {
throw Error('Worker could not be found in tasks map')
}
}
/**
- *
In
crease the number of tasks that the given workers has done.
+ *
De
crease the number of tasks that the given workers has done.
*
*
- * @param worker Workers whose tasks are
in
creased.
+ * @param worker Workers whose tasks are
de
creased.
*/
protected decreaseWorkersTasks (worker: Worker): void {
*/
protected decreaseWorkersTasks (worker: Worker): void {
- const numberOfTasks
TheWorkerHa
s = this.tasks.get(worker)
- if (numberOfTasks
TheWorkerHa
s !== undefined) {
- this.tasks.set(worker, numberOfTasks
TheWorkerHa
s - 1)
+ const numberOfTasks
InProgres
s = this.tasks.get(worker)
+ if (numberOfTasks
InProgres
s !== undefined) {
+ this.tasks.set(worker, numberOfTasks
InProgres
s - 1)
} else {
throw Error('Worker could not be found in tasks map')
}
} else {
throw Error('Worker could not be found in tasks map')
}
diff --git
a/src/pools/cluster/dynamic.ts
b/src/pools/cluster/dynamic.ts
index f6c70126f41599b482c6a653923dad3a66bed964..5eba843a3ae0726a3102d3068deced8679058844 100644
(file)
--- a/
src/pools/cluster/dynamic.ts
+++ b/
src/pools/cluster/dynamic.ts
@@
-62,7
+62,9
@@
export class DynamicClusterPool<
const worker = this.createAndSetupWorker()
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const worker = this.createAndSetupWorker()
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
- if (message.kill && !tasksInProgress) {
+ if (message.kill && tasksInProgress === 0) {
+ // Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime)
+ // To handle the case of a long-running task we will check if there is any active task
this.sendToWorker(worker, { kill: 1 })
void this.destroyWorker(worker)
}
this.sendToWorker(worker, { kill: 1 })
void this.destroyWorker(worker)
}
diff --git
a/src/pools/thread/dynamic.ts
b/src/pools/thread/dynamic.ts
index 74013f2b70dceaf0e35ece2bbd9c25c5d0168701..26d81d2fc15c99aa33a12088e225ab0889f534f4 100644
(file)
--- a/
src/pools/thread/dynamic.ts
+++ b/
src/pools/thread/dynamic.ts
@@
-62,9
+62,9
@@
export class DynamicThreadPool<
const worker = this.createAndSetupWorker()
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const worker = this.createAndSetupWorker()
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
- if (message.kill &&
!tasksInProgress
) {
- // Kill received from the worker, means that no new tasks are submitted to that worker for a while( > maxInactiveTime)
- // To handle the case of a long-running task we will check if the
the
re is any active task
+ if (message.kill &&
tasksInProgress === 0
) {
+ // Kill received from the worker, means that no new tasks are submitted to that worker for a while
( > maxInactiveTime)
+ // To handle the case of a long-running task we will check if there is any active task
this.sendToWorker(worker, { kill: 1 })
void this.destroyWorker(worker)
}
this.sendToWorker(worker, { kill: 1 })
void this.destroyWorker(worker)
}