import { pipe } from "../../Function"
import * as Q from "../../Queue"
import * as T from "../_internal/effect"
import * as M from "../_internal/managed"
import { bufferSignal } from "./_internal/bufferSignal"
import { Stream } from "./definitions"
/**
 * Allows a faster producer to progress independently of a slower consumer by buffering
 * up to `capacity` elements in a dropping queue.
 *
 * @note Prefer capacities that are powers of 2 for better performance.
 */

export function bufferDropping_(self, capacity) {
  return new Stream(
    M.chain_(
      M.bind_(M.do, "queue", () =>
        T.toManagedRelease_(Q.makeDropping(capacity), Q.shutdown)
      ),
      ({ queue }) => bufferSignal(self, queue)
    )
  )
}
/**
 * Allows a faster producer to progress independently of a slower consumer by buffering
 * up to `capacity` elements in a dropping queue.
 *
 * @note Prefer capacities that are powers of 2 for better performance.
 */

export function bufferDropping(capacity) {
  return (self) => bufferDropping_(self, capacity)
}
//# sourceMappingURL=bufferDropping.js.map
