import { fromTask } from "../_core"; import * as T from "../_internal/task"; import { onExitFirst_ } from "./onExitFirst"; /** * Lifts a `Task` into `Managed` with a release action. * The acquire action will be performed interruptibly, while release * will be performed uninterruptibly. */ export const makeInterruptible = (release: (a: A) => T.Task) => ( acquire: T.Task ) => _makeInterruptible(acquire, release); /** * Lifts a `Task` into `Managed` with a release action. * The acquire action will be performed interruptibly, while release * will be performed uninterruptibly. */ export const _makeInterruptible = ( acquire: T.Task, release: (a: A) => T.Task ) => onExitFirst_(fromTask(acquire), (e) => { switch (e._tag) { case "Failure": { return T.unit(); } case "Success": { return release(e.value); } } });