MCPcopy Create free account
hub / github.com/effect-app/libs / resizeLoop

Function resizeLoop

repos/effect/packages/effect/src/Pool.ts:545–559  ·  view source on GitHub ↗
(self: Pool<A, E>)

Source from the content-addressed store, hash-verified

543
544const resize = <A, E>(self: Pool<A, E>): Effect.Effect<void> =>
545 self.state.resizeSemaphore.withPermits(1)(resizeLoop(self))
546
547const resizeLoop = <A, E>(self: Pool<A, E>): Effect.Effect<void> =>
548 Effect.suspend(() => {
549 const active = activeSize(self)
550 const target = targetSize(self)
551 if (active >= target) {
552 return Effect.void
553 }
554 const toAcquire = target - active
555 return self.config.strategy.reclaim(self).pipe(
556 Effect.flatMap((item) => item ? Effect.succeed(item) : allocate(self)),
557 Effect.replicateEffect(toAcquire, { concurrency: toAcquire }),
558 Effect.tap(self.state.availableLatch.open),
559 Effect.flatMap((items) => items.some((_) => _.exit._tag === "Failure") ? Effect.void : resizeLoop(self))
560 )
561 })
562

Callers 1

resizeFunction · 0.85

Calls 6

activeSizeFunction · 0.85
targetSizeFunction · 0.85
someMethod · 0.80
allocateFunction · 0.70
pipeMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…