import * as tsplus_module_1 from "@effect/core/stream/Stream/operations/runIntoQueueElementsScoped";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/fork";
import * as tsplus_module_3 from "@effect/core/io/Queue/external/bounded";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/acquireRelease";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/tap";
/**
 * Converts the stream to a scoped queue of elements. After the scope is
 * closed, the queue will never again produce values and should be discarded.
 *
 * @tsplus fluent ets/Stream toQueueOfElements
 */

export function toQueueOfElements_(self, capacity = 2, __tsplusTrace) {
  return tsplus_module_5.tap_(tsplus_module_4.acquireRelease(() => tsplus_module_3.bounded(capacity, __tsplusTrace), queue => queue.shutdown, __tsplusTrace), queue => tsplus_module_2.fork(tsplus_module_1.runIntoQueueElementsScoped_(self, () => queue, __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * Converts the stream to a scoped queue of elements. After the scope is
 * closed, the queue will never again produce values and should be discarded.
 *
 * @tsplus static ets/Stream/Aspects toQueueOfElements
 */

export const toQueueOfElements = (capacity = 2, __tsplusTrace) => self => toQueueOfElements_(self, capacity, __tsplusTrace);
//# sourceMappingURL=toQueueOfElements.mjs.map