MCPcopy Create free account
hub / github.com/Effect-TS/effect / invalidatePoolItem

Function invalidatePoolItem

packages/effect/src/Pool.ts:1041–1063  ·  view source on GitHub ↗
(self: Pool<A, E>, poolItem: PoolItem<A, E>)

Source from the content-addressed store, hash-verified

1039 })
1040
1041const invalidatePoolItem = <A, E>(self: Pool<A, E>, poolItem: PoolItem<A, E>): Effect.Effect<void> =>
1042 Effect.suspend(() => {
1043 if (!self.state.items.has(poolItem)) {
1044 return Effect.void
1045 } else if (poolItem.refCount === 0) {
1046 self.state.items.delete(poolItem)
1047 removeAvailable(self, poolItem)
1048 self.state.invalidated.delete(poolItem)
1049 return Effect.asVoid(Effect.flatMap(
1050 poolItem.finalizer,
1051 () => Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope, { startImmediately: true })
1052 ))
1053 }
1054 self.state.invalidated.add(poolItem)
1055 removeAvailable(self, poolItem)
1056 // An invalidated item stops counting towards the pool's active size, so the
1057 // pool is now below target and has to top itself back up. Waiting for the
1058 // last lease to be returned would strand anybody already queued: the item
1059 // they are waiting for is never coming back.
1060 return Effect.asVoid(
1061 Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope, { startImmediately: true })
1062 )
1063 })
1064
1065// `failures` is the failure count when a borrower requested the resize or the
1066// previous pass ran. Startup and invalidation refills omit it.

Callers 3

makeReturnLeaseFunction · 0.85
Pool.tsFile · 0.85
processFunction · 0.85

Calls 5

removeAvailableFunction · 0.85
resizeFunction · 0.70
hasMethod · 0.65
deleteMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected