import * as tsplus_module_1 from "@effect/core/io/Effect/operations/suspendSucceed";
import { IEnsuring } from "@effect/core/io/Effect/definition/primitives";
/**
 * Returns an effect that, if this effect _starts_ execution, then the
 * specified `finalizer` is guaranteed to begin execution, whether this effect
 * succeeds, fails, or is interrupted.
 *
 * For use cases that need access to the effect's result, see `onExit`.
 *
 * Finalizers offer very powerful guarantees, but they are low-level, and
 * should generally not be used for releasing resources. For higher-level
 * logic built on `ensuring`, see `acquireReleaseWith`.
 *
 * @tsplus fluent ets/Effect ensuring
 */

export function ensuring_(self, finalizer, __tsplusTrace) {
  return tsplus_module_1.suspendSucceed(() => new IEnsuring(self, finalizer(), __tsplusTrace), __tsplusTrace);
}
/**
 * Returns an effect that, if this effect _starts_ execution, then the
 * specified `finalizer` is guaranteed to begin execution, whether this effect
 * succeeds, fails, or is interrupted.
 *
 * For use cases that need access to the effect's result, see `onExit`.
 *
 * Finalizers offer very powerful guarantees, but they are low-level, and
 * should generally not be used for releasing resources. For higher-level
 * logic built on `ensuring`, see `acquireReleaseWith`.
 *
 * @tsplus static ets/Effect/Aspects ensuring
 */

export const ensuring = (finalizer, __tsplusTrace) => self => ensuring_(self, finalizer, __tsplusTrace);
//# sourceMappingURL=ensuring.mjs.map