checkPoolSize method
Implementation
FutureOr<bool> checkPoolSize(
int minSize, int maxSize, int checkInvalidsIntervalMs) {
var poolSize = this.poolSize;
if (poolSize <= minSize) {
if (lastCheckPoolElapsedTimeMs > checkInvalidsIntervalMs) {
return removeInvalidElementsFromPool(checkUsage: false);
} else {
return true;
}
}
if (poolSize > maxSize) {
return removeInvalidElementsFromPool().resolveMapped((_) {
var excess = this.poolSize - maxSize;
_logPool.info(
"Removing excess> poolSize: $poolSize ; maxSize: $maxSize ; excess: $excess");
removeElementsFromPool(excess);
return true;
});
}
if (lastCheckPoolElapsedTimeMs > checkInvalidsIntervalMs) {
return removeInvalidElementsFromPool();
} else {
return true;
}
}