Skip to content

Commit

Permalink
account for invalidated in usage strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed May 28, 2024
1 parent 700bc04 commit 819f837
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/effect/src/internal/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class PoolImpl<A, E> implements Pool<A, E> {
return this.getPoolItem
} else if (poolItem.exit._tag === "Failure") {
this.items.delete(poolItem)
this.invalidated.delete(poolItem)
return core.succeed(poolItem)
}
poolItem.refCount++
Expand Down Expand Up @@ -311,7 +312,7 @@ const strategyUsageTTL = <A, E>(ttl: Duration.DurationInput) =>
return identity<Strategy<A, E>>({
run: (pool) => {
const process: Effect<void> = core.suspend(() => {
const excess = pool.items.size - pool.targetSize
const excess = pool.items.size - pool.invalidated.size - pool.targetSize
if (excess <= 0) return core.void
return queue.take.pipe(
core.tap((item) => pool.invalidatePoolItem(item)),
Expand Down

0 comments on commit 819f837

Please sign in to comment.