import * as tsplus_module_1 from "@effect/core/stream/Stream/operations/fromQueue";
import * as tsplus_module_2 from "@effect/core/stream/Stream/operations/ensuring";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/succeed";
import * as tsplus_module_4 from "@effect/core/stream/Stream/operations/flatMap";
import { DEFAULT_CHUNK_SIZE } from "@effect/core/stream/Stream/definition";
/**
 * Creates a stream from a `Queue` of values. The queue will be shutdown once
 * the stream is closed.
 *
 * @param maxChunkSize
 *   Maximum number of queued elements to put in one chunk in the stream.
 *
 * @tsplus static ets/Stream/Ops fromQueueWithShutdown
 */

export function fromQueueWithShutdown(queue, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
  return tsplus_module_4.flatMap_(tsplus_module_3.succeed(queue, __tsplusTrace), queue => tsplus_module_2.ensuring_(tsplus_module_1.fromQueue(() => queue, maxChunkSize, __tsplusTrace), () => queue.shutdown, __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=fromQueueWithShutdown.mjs.map