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

Function get

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

Source from the content-addressed store, hash-verified

506 * @since 2.0.0
507 */
508export const get = <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope> =>
509 core.withFiber((fiber) => {
510 const state = self.state
511 if (state.isShuttingDown) return internal.interrupt
512 if (state.waiters.size === 0 && state.availableHead?.exit._tag === "Success") {
513 state.usage++
514 if (self.config.isFixed || targetSize(self) <= activeSize(self)) {
515 return leaseItem(self, state.availableHead, fiber)
516 }
517 state.usage--
518 }
519 return getSlowWith(self, leaseItemWith)
520 })
521
522/**
523 * Borrows an item while an effect runs and returns it when the effect exits.

Callers

nothing calls this directly

Calls 4

targetSizeFunction · 0.85
activeSizeFunction · 0.85
leaseItemFunction · 0.85
getSlowWithFunction · 0.85

Tested by

no test coverage detected