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

Function tryAcquire

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

Source from the content-addressed store, hash-verified

336 * @since 4.0.0
337 */
338export const tryAcquire = (self: TxSemaphore): Effect.Effect<boolean> =>
339 TxRef.modify(self.permitsRef, (permits: number) => {
340 if (permits > 0) {
341 return [true, permits - 1]
342 }
343 return [false, permits]
344 })
345
346/**
347 * Tries to acquire the specified number of permits from the semaphore without

Callers

nothing calls this directly

Calls 1

modifyMethod · 0.65

Tested by

no test coverage detected