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

Function acquire

packages/effect/src/TxSemaphore.ts:241–248  ·  view source on GitHub ↗
(self: TxSemaphore)

Source from the content-addressed store, hash-verified

239 * @since 2.0.0
240 */
241export const acquire = (self: TxSemaphore): Effect.Effect<void> =>
242 Effect.gen(function*() {
243 const permits = yield* TxRef.get(self.permitsRef)
244 if (permits <= 0) {
245 return yield* Effect.txRetry
246 }
247 yield* TxRef.set(self.permitsRef, permits - 1)
248 }).pipe(Effect.tx)
249
250/**
251 * Acquires the specified number of permits from the semaphore.

Callers 3

TxSemaphore.tsFile · 0.85
withPermitScopedFunction · 0.85
ResourceRefClass · 0.85

Calls 3

pipeMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected