repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perf: avoid branching on pool type
[poolifier.git]
/
src
/
pools
/
cluster
/
dynamic.ts
diff --git
a/src/pools/cluster/dynamic.ts
b/src/pools/cluster/dynamic.ts
index 75296f7a1a894d45b51b65727610f53f361d6fc9..08ebc75c76a66ba5ca311c2e269988d741ad5aff 100644
(file)
--- a/
src/pools/cluster/dynamic.ts
+++ b/
src/pools/cluster/dynamic.ts
@@
-1,4
+1,5
@@
-import { type PoolType, PoolTypes } from '../pool'
+import { checkDynamicPoolSize } from '../utils'
+import { PoolEvents, type PoolType, PoolTypes } from '../pool'
import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
/**
import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
/**
@@
-26,22
+27,32
@@
export class DynamicClusterPool<
*/
public constructor (
min: number,
*/
public constructor (
min: number,
-
protected readonly
max: number,
+ max: number,
filePath: string,
opts: ClusterPoolOptions = {}
) {
filePath: string,
opts: ClusterPoolOptions = {}
) {
- super(min, filePath, opts)
- this.checkDynamicPoolSize(this.numberOfWorkers, this.max)
+ super(min, filePath, opts, max)
+ checkDynamicPoolSize(
+ this.minimumNumberOfWorkers,
+ this.maximumNumberOfWorkers as number
+ )
}
/** @inheritDoc */
}
/** @inheritDoc */
- protected
get type (): PoolType
{
- return
PoolTypes.dynamic
+ protected
shallCreateDynamicWorker (): boolean
{
+ return
!this.full && this.internalBusy()
}
/** @inheritDoc */
}
/** @inheritDoc */
- protected get maxSize (): number {
- return this.max
+ protected checkAndEmitDynamicWorkerCreationEvents (): void {
+ if (this.full) {
+ this.emitter?.emit(PoolEvents.full, this.info)
+ }
+ }
+
+ /** @inheritDoc */
+ protected get type (): PoolType {
+ return PoolTypes.dynamic
}
/** @inheritDoc */
}
/** @inheritDoc */