Skip to content

Commit

Permalink
reconcile if waiters
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed May 28, 2024
1 parent d476d97 commit 75a0dc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/effect/src/internal/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ class PoolImpl<A, E> implements Pool<A, E> {
if (poolItem.refCount === 0) {
this.items.delete(poolItem)
this.invalidated.delete(poolItem)
return poolItem.finalizer
return this.waiters > 0
? Effect.zipRight(poolItem.finalizer, this.reconcile)
: poolItem.finalizer
}
this.invalidated.add(poolItem)
return Effect.void
Expand Down
7 changes: 4 additions & 3 deletions packages/effect/test/KeyedPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ describe("KeyedPool", () => {
() =>
Effect.scoped(pipe(
KeyedPool.get(pool, "key1"),
Effect.flatMap((value) =>
Effect.zipRight(
Effect.flatMap((value) => {
console.log("get", value)
return Effect.zipRight(
Effect.whenEffect(
KeyedPool.invalidate(pool, value),
Random.nextBoolean
Expand All @@ -68,7 +69,7 @@ describe("KeyedPool", () => {
(n) => Effect.sleep(Duration.millis(n))
)
)
)
})
)),
{ concurrency: "unbounded", discard: true }
)
Expand Down

0 comments on commit 75a0dc5

Please sign in to comment.