(open?: boolean | undefined): Effect.Effect<Latch>Creates a Latch inside Effect.
When to use
Use to create a latch for coordinating fibers inside Effect code.
Details
The latch starts closed by default; pass true to create it open.
Example (Creating a latch)
import { Effect, Latch } from "effect"
const program = Effect.gen(function*() {
const latch = yield* Latch.make(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
})
yield* Effect.all([waiter, opener])
})constructorsmakeUnsafe
Source effect/Latch.ts:2081 lines
export const const make: (
open?: boolean | undefined
) => Effect.Effect<Latch>
Creates a Latch inside Effect.
When to use
Use to create a latch for coordinating fibers inside Effect code.
Details
The latch starts closed by default; pass true to create it open.
Example (Creating a latch)
import { Effect, Latch } from "effect"
const program = Effect.gen(function*() {
const latch = yield* Latch.make(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
})
yield* Effect.all([waiter, opener])
})
make: (open: boolean | undefinedopen?: boolean | undefined) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<Latch> = import internalinternal.const makeLatch: (
open?: boolean | undefined
) => Effect.Effect<A>
makeLatchReferenced by 1 symbols