effect-io-ai

Package: effect
Module: TxReentrantLock

TxReentrantLock.acquireRead

Acquires a read lock. Blocks if another fiber holds the write lock. If the current fiber already holds the write lock, the read lock is granted (reentrancy). Returns the current number of read locks held by this fiber.

Example (Acquiring a read lock)

import { Effect, TxReentrantLock } from "effect"

const program = Effect.gen(function*() {
  const lock = yield* TxReentrantLock.make()
  const count = yield* TxReentrantLock.acquireRead(lock)
  console.log(count) // 1
  yield* TxReentrantLock.releaseRead(lock)
})

Signature

declare const acquireRead: (self: TxReentrantLock) => Effect.Effect<number>

Source

Since v2.0.0