import * as tsplus_module_1 from "@effect/core/io/Fiber/operations/interrupt";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/addFinalizer";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/forkDaemon";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/tap";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/interruption";
/**
 * Forks the fiber in a `Scope`, interrupting it when the scope is closed.
 *
 * @tsplus fluent ets/Effect forkScoped
 */

export function forkScoped(self, __tsplusTrace) {
  return tsplus_module_5.uninterruptibleMask(({
    restore
  }) => tsplus_module_4.tap_(tsplus_module_3.forkDaemon(restore(() => self, __tsplusTrace), __tsplusTrace), fiber => tsplus_module_2.addFinalizer(() => tsplus_module_1.interrupt(fiber, __tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=forkScoped.mjs.map