(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])
})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.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<Latch> = import internalinternal.const makeLatch: (
open?: boolean | undefined
) => Effect.Effect<Latch, never, never>
makeLatch