repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: align findFreeWorkerKey() return type with findIndex()
[poolifier.git]
/
src
/
pools
/
abstract-pool.ts
diff --git
a/src/pools/abstract-pool.ts
b/src/pools/abstract-pool.ts
index 095a4f7b99840ff1c0ff9074d6cd66dca2efa1d0..66b1ea1da3f3ba47d93cda9c94d2b2a19cc63ac3 100644
(file)
--- a/
src/pools/abstract-pool.ts
+++ b/
src/pools/abstract-pool.ts
@@
-146,7
+146,7
@@
export abstract class AbstractPool<
* Gets the given worker key.
*
* @param worker - The worker.
* Gets the given worker key.
*
* @param worker - The worker.
- * @returns The worker key.
+ * @returns The worker key
if the worker is found in the pool, `-1` otherwise
.
*/
private getWorkerKey (worker: Worker): number {
return this.workers.findIndex(workerItem => workerItem.worker === worker)
*/
private getWorkerKey (worker: Worker): number {
return this.workers.findIndex(workerItem => workerItem.worker === worker)
@@
-177,16
+177,15
@@
export abstract class AbstractPool<
protected internalGetBusyStatus (): boolean {
return (
this.numberOfRunningTasks >= this.numberOfWorkers &&
protected internalGetBusyStatus (): boolean {
return (
this.numberOfRunningTasks >= this.numberOfWorkers &&
- this.findFreeWorkerKey() ===
false
+ this.findFreeWorkerKey() ===
-1
)
}
/** {@inheritDoc} */
)
}
/** {@inheritDoc} */
- public findFreeWorkerKey (): number
| false
{
-
const freeWorkerKey =
this.workers.findIndex(workerItem => {
+ public findFreeWorkerKey (): number {
+
return
this.workers.findIndex(workerItem => {
return workerItem.tasksUsage.running === 0
})
return workerItem.tasksUsage.running === 0
})
- return freeWorkerKey !== -1 ? freeWorkerKey : false
}
/** {@inheritDoc} */
}
/** {@inheritDoc} */