Hyperlinkv0.8.0-beta.28

TxQueue

TxQueue.interruptconsteffect/TxQueue.ts:1135
<A, E>(self: TxEnqueue<A, E>): Effect.Effect<boolean>

Interrupts the queue gracefully with the current fiber's interruption cause.

Details

If the queue still contains items, it enters the closing state so buffered items can be drained before consumers observe the interruption. If it is empty, it transitions directly to done. Returns false if the queue was already closing or done.

Example (Interrupting queues)

import { Effect, TxQueue } from "effect"

const program = Effect.gen(function*() {
  const queue = yield* TxQueue.bounded<number>(10)
  yield* TxQueue.offer(queue, 42)

  // Interrupt gracefully - allows remaining items to be consumed
  const result = yield* TxQueue.interrupt(queue)
  console.log(result) // true
})
combinators
export const interrupt = <A, E>(self: TxEnqueue<A, E>): Effect.Effect<boolean> =>
  Effect.withFiber((fiber) => failCause(self, Cause.interrupt(fiber.id)))
Referenced by 1 symbols