(
register: (emit: Emit.Emit<R, E, A, void>) => Effect.Effect<unknown, E, R | Scope.Scope>,
bufferSize?: number | "unbounded" | {
readonly bufferSize?: number | undefined
readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
} | undefined
)
| 632 | |
| 633 | /** @internal */ |
| 634 | export const asyncScoped = <A, E = never, R = never>( |
| 635 | register: (emit: Emit.Emit<R, E, A, void>) => Effect.Effect<unknown, E, R | Scope.Scope>, |
| 636 | bufferSize?: number | "unbounded" | { |
| 637 | readonly bufferSize?: number | undefined |
| 638 | readonly strategy?: "dropping" | "sliding" | "suspend" | undefined |
| 639 | } | undefined |
| 640 | ): Stream.Stream<A, E, Exclude<R, Scope.Scope>> => |
| 641 | pipe( |
| 642 | Effect.acquireRelease( |
| 643 | queueFromBufferOptions<A, E>(bufferSize), |
| 644 | (queue) => Queue.shutdown(queue) |
| 645 | ), |
| 646 | Effect.flatMap((output) => |
| 647 | pipe( |
| 648 | Effect.runtime<R>(), |
| 649 | Effect.flatMap((runtime) => |
| 650 | pipe( |
| 651 | register( |
| 652 | emit.make((k) => |
| 653 | pipe( |
| 654 | InternalTake.fromPull(k), |
| 655 | Effect.flatMap((take) => Queue.offer(output, take)), |
| 656 | Effect.asVoid, |
| 657 | Runtime.runPromiseExit(runtime) |
| 658 | ).then((exit) => { |
| 659 | if (Exit.isFailure(exit)) { |
| 660 | if (!Cause.isInterrupted(exit.cause)) { |
| 661 | throw Cause.squash(exit.cause) |
| 662 | } |
| 663 | } |
| 664 | }) |
| 665 | ) |
| 666 | ), |
| 667 | Effect.zipRight(Ref.make(false)), |
| 668 | Effect.flatMap((ref) => |
| 669 | pipe( |
| 670 | Ref.get(ref), |
| 671 | Effect.map((isDone) => |
| 672 | isDone ? |
| 673 | pull.end() : |
| 674 | pipe( |
| 675 | Queue.take(output), |
| 676 | Effect.flatMap(InternalTake.done), |
| 677 | Effect.onError(() => |
| 678 | pipe( |
| 679 | Ref.set(ref, true), |
| 680 | Effect.zipRight(Queue.shutdown(output)) |
| 681 | ) |
| 682 | ) |
| 683 | ) |
| 684 | ) |
| 685 | ) |
| 686 | ) |
| 687 | ) |
| 688 | ) |
| 689 | ) |
| 690 | ), |
| 691 | scoped, |
nothing calls this directly
no test coverage detected