| 1 | import type * as Cause from "../../Cause.ts" |
| 2 | import * as Effect from "../../Effect.ts" |
| 3 | import * as Fiber from "../../Fiber.ts" |
| 4 | import { Abandon } from "../ClusterSchema.ts" |
| 5 | |
| 6 | export const interrupt: Effect.Effect<never> = Effect.interruptible( |
| 7 | Effect.callback<never>(() => { |
| 8 | const fiber = Fiber.getCurrent()! |
| 9 | fiber.interruptUnsafe(fiber.id, Abandon.annotation) |
| 10 | }) |
| 11 | ) |
| 12 | |
| 13 | export const isCause = (cause: Cause.Cause<unknown>): boolean => |
| 14 | cause.reasons.some((reason) => reason._tag === "Interrupt" && reason.annotations.has(Abandon.key)) |