(self: TxSemaphore)
| 239 | * @since 2.0.0 |
| 240 | */ |
| 241 | export 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. |
no test coverage detected