<A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>Retrieves an item from the pool in a scoped effect.
When to use
Use to borrow a pooled resource for the lifetime of the current scope so it is automatically returned when that scope closes.
Details
The returned effect waits for an available item when the pool is at capacity. If acquiring a new item fails, the effect fails with the acquisition error.
Gotchas
Retrying a failed get can repeat the acquisition attempt.
export const const get: <A, E>(
self: Pool<A, E>
) => Effect.Effect<A, E, Scope.Scope>
Retrieves an item from the pool in a scoped effect.
When to use
Use to borrow a pooled resource for the lifetime of the current scope so it
is automatically returned when that scope closes.
Details
The returned effect waits for an available item when the pool is at capacity.
If acquiring a new item fails, the effect fails with the acquisition error.
Gotchas
Retrying a failed get can repeat the acquisition attempt.
get = <function (type parameter) A in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>A, function (type parameter) E in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>E>(self: Pool<A, E>(parameter) self: {
config: Config<A, E>;
state: State<A, E>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface Pool<in out A, in out E = never>A Pool<A, E> is a pool of items of type A, each of which may be
associated with the acquisition and release of resources. An attempt to get
an item A from a pool may fail with an error of type E.
When to use
Use when you need to share a bounded set of scoped resources across fibers
while the pool manages acquisition, reuse, and release.
Pool<function (type parameter) A in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>A, function (type parameter) E in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>E>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>A, function (type parameter) E in <A, E>(self: Pool<A, E>): Effect.Effect<A, E, Scope.Scope>E, import ScopeScope.Scope> =>
import EffectEffect.suspend(() => {
if (self: Pool<A, E>(parameter) self: {
config: Config<A, E>;
state: State<A, E>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self.Pool<A, E>.state: State<A, E>(property) Pool<A, E>.state: {
scope: Scope.Scope;
isShuttingDown: boolean;
semaphore: Semaphore.Semaphore;
resizeSemaphore: Semaphore.Semaphore;
items: Set<PoolItem<A, E>>;
available: Set<PoolItem<A, E>>;
availableLatch: Latch.Latch;
invalidated: Set<PoolItem<A, E>>;
waiters: number;
}
state.State<A, E>.isShuttingDown: booleanisShuttingDown) {
return import EffectEffect.interrupt
}
return import EffectEffect.flatMap(const getPoolItem: <A, E>(
self: Pool<A, E>
) => Effect.Effect<
PoolItem<A, E>,
never,
Scope.Scope
>
getPoolItem(self: Pool<A, E>(parameter) self: {
config: Config<A, E>;
state: State<A, E>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self), (item: PoolItem<A, E>(parameter) item: {
exit: Exit.Exit<A, E>;
finalizer: Effect.Effect<void>;
refCount: number;
disableReclaim: boolean;
}
item) => item: PoolItem<A, E>(parameter) item: {
exit: Exit.Exit<A, E>;
finalizer: Effect.Effect<void>;
refCount: number;
disableReclaim: boolean;
}
item.exit)
})