Hyperlinkv0.8.0-beta.28

TxReentrantLock

TxReentrantLock.makeconsteffect/TxReentrantLock.ts:107
(): Effect.Effect<TxReentrantLock>

Creates a new TxReentrantLock.

Example (Creating a reentrant lock)

import { Effect, TxReentrantLock } from "effect"

const program = Effect.gen(function*() {
  const lock = yield* TxReentrantLock.make()
  const isLocked = yield* TxReentrantLock.locked(lock)
  console.log(isLocked) // false
})
constructors
export const make = (): Effect.Effect<TxReentrantLock> =>
  Effect.gen(function*() {
    const stateRef = yield* TxRef.make<LockState>(emptyState)
    const self = Object.create(TxReentrantLockProto)
    self[TypeId] = TypeId
    self.stateRef = stateRef
    return self
  }).pipe(Effect.tx)