(open?: boolean | undefined): LatchCreates a Latch synchronously, outside of Effect.
When to use
Use when you need to allocate a Latch synchronously outside an Effect
workflow.
Details
The latch starts closed by default; pass true to create it open.
Example (Creating a latch unsafely)
import { Effect, Latch } from "effect"
const latch = Latch.makeUnsafe(false)
const waiter = Effect.gen(function*() {
yield* Effect.log("Waiting for latch to open...")
yield* latch.await
yield* Effect.log("Latch opened! Continuing...")
})
const opener = Effect.gen(function*() {
yield* Effect.sleep("2 seconds")
yield* Effect.log("Opening latch...")
yield* latch.open
})
const program = Effect.all([waiter, opener])constructorsmake
Source effect/Latch.ts:1661 lines
export const const makeUnsafe: (
open?: boolean | undefined
) => Latch
Creates a Latch synchronously, outside of Effect.
When to use
Use when you need to allocate a Latch synchronously outside an Effect
workflow.
Details
The latch starts closed by default; pass true to create it open.
Example (Creating a latch unsafely)
import { Effect, Latch } from "effect"
const latch = Latch.makeUnsafe(false)
const waiter = Effect.gen(function*() {
yield* Effect.log("Waiting for latch to open...")
yield* latch.await
yield* Effect.log("Latch opened! Continuing...")
})
const opener = Effect.gen(function*() {
yield* Effect.sleep("2 seconds")
yield* Effect.log("Opening latch...")
yield* latch.open
})
const program = Effect.all([waiter, opener])
makeUnsafe: (open: boolean | undefinedopen?: boolean | undefined) => Latch = import internalinternal.const makeLatchUnsafe: (
open?: boolean | undefined
) => _Latch.Latch
makeLatchUnsafeReferenced by 8 symbols