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

Function finalizersMaskInternal

packages/effect/src/internal/fiberRuntime.ts:2836–2865  ·  view source on GitHub ↗
(strategy: ExecutionStrategy.ExecutionStrategy, concurrentFinalizers?: boolean | undefined)

Source from the content-addressed store, hash-verified

2834/* @internal */
2835export const finalizersMaskInternal =
2836 (strategy: ExecutionStrategy.ExecutionStrategy, concurrentFinalizers?: boolean | undefined) =>
2837 <A, E, R>(
2838 self: (
2839 restore: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, E1, R1>
2840 ) => Effect.Effect<A, E, R>
2841 ): Effect.Effect<A, E, R> =>
2842 core.contextWithEffect((context) =>
2843 Option.match(Context.getOption(context, scopeTag), {
2844 onNone: () => self(identity),
2845 onSome: (scope) => {
2846 if (concurrentFinalizers === true) {
2847 const patch = strategy._tag === "Parallel"
2848 ? parallelFinalizers
2849 : strategy._tag === "Sequential"
2850 ? sequentialFinalizers
2851 : parallelNFinalizers(strategy.parallelism)
2852 switch (scope.strategy._tag) {
2853 case "Parallel":
2854 return patch(self(parallelFinalizers))
2855 case "Sequential":
2856 return patch(self(sequentialFinalizers))
2857 case "ParallelN":
2858 return patch(self(parallelNFinalizers(scope.strategy.parallelism)))
2859 }
2860 } else {
2861 return self(identity)
2862 }
2863 }
2864 })
2865 )
2866
2867/* @internal */
2868export const scopeWith = <A, E, R>(

Callers 2

fiberRuntime.tsFile · 0.85
finalizersMaskFunction · 0.85

Calls 3

parallelNFinalizersFunction · 0.85
getOptionMethod · 0.65
patchFunction · 0.50

Tested by

no test coverage detected