const fileName_1 = "(@effect/core) _src/stream/Channel/operations/acquireUseReleaseExit.ts";
import * as tsplus_module_1 from "@effect/core/io/Effect/operations/flatMap";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/tap";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/interruption";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/flatMap";
import * as tsplus_module_6 from "@effect/core/stream/Channel/operations/ensuringWith";
import * as tsplus_module_7 from "@effect/core/io/Effect/operations/unit";
import * as tsplus_module_8 from "@effect/core/io/Ref/operations/make";
/**
 * @tsplus static ets/Channel/Ops acquireUseReleaseExit
 */

export function acquireUseReleaseExit(acquire, use, release) {
  return tsplus_module_5.flatMap_(tsplus_module_4.fromEffect(() => tsplus_module_8.makeRef(() => _ => tsplus_module_7.unit, fileName_1 + ":19:13")), ref => tsplus_module_6.ensuringWith_(tsplus_module_5.flatMap_(tsplus_module_4.fromEffect(() => tsplus_module_3.uninterruptible(tsplus_module_2.tap_(acquire(), a => ref.set(exit => release(a, exit), fileName_1 + ":23:28"), fileName_1 + ":23:13"), fileName_1 + ":24:25")), use), exit => tsplus_module_1.flatMap_(ref.get(fileName_1 + ":27:38"), f => f(exit), fileName_1 + ":27:48")));
}
//# sourceMappingURL=acquireUseReleaseExit.mjs.map