MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/FiberMap.ts:162–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160 * @since 2.0.0
161 */
162export const make = <K, A = unknown, E = unknown>(): Effect.Effect<FiberMap<K, A, E>, never, Scope.Scope> =>
163 Effect.acquireRelease(
164 Effect.sync(() =>
165 makeUnsafe<K, A, E>(
166 MutableHashMap.empty(),
167 Deferred.makeUnsafe()
168 )
169 ),
170 (map) =>
171 Effect.suspend(() => {
172 const state = map.state
173 if (state._tag === "Closed") return Effect.void
174 map.state = { _tag: "Closed" }
175 return Fiber.interruptAll(MutableHashMap.values(state.backing)).pipe(
176 Deferred.into(map.deferred)
177 )
178 })
179 )
180
181/**
182 * Creates a scoped run function that forks effects into a new `FiberMap`.

Callers 2

makeRuntimeFunction · 0.70
makeRuntimePromiseFunction · 0.70

Calls 3

makeUnsafeFunction · 0.70
pipeMethod · 0.65
syncMethod · 0.45

Tested by

no test coverage detected