import { Effect } from "@effect/core/io/Effect/definition"; import { Cause } from "@effect/core/io/Cause/definition"; import { Deferred } from "@effect/core/io/Deferred/definition"; import { ImmutableQueue } from "@tsplus/stdlib/collections/ImmutableQueue/definition"; import { Either } from "@tsplus/stdlib/data/Either/definition"; import { Ref } from "@effect/core/io/Ref/definition"; import { Exit } from "@effect/core/io/Exit/definition"; /** * Producer-side view of `SingleProducerAsyncInput` for variance purposes. */ export interface AsyncInputProducer { readonly emit: (el: Elem) => Effect; readonly done: (a: Done) => Effect; readonly error: (cause: Cause) => Effect; readonly awaitRead: Effect; } /** * Consumer-side view of `SingleProducerAsyncInput` for variance purposes. */ export interface AsyncInputConsumer { readonly takeWith: (onError: (cause: Cause) => A, onElement: (element: Elem) => A, onDone: (done: Done) => A) => Effect; } export type State = StateEmpty | StateEmit | StateError | StateDone; export declare const DoneTypeId: unique symbol; export type DoneTypeId = typeof DoneTypeId; export declare class StateDone { readonly a: Elem; readonly _typeId: DoneTypeId; constructor(a: Elem); } export declare const ErrorTypeId: unique symbol; export type ErrorTypeId = typeof ErrorTypeId; export declare class StateError { readonly cause: Cause; readonly _typeId: ErrorTypeId; constructor(cause: Cause); } export declare const EmptyTypeId: unique symbol; export type EmptyTypeId = typeof EmptyTypeId; export declare class StateEmpty { readonly notifyProducer: Deferred; readonly _typeId: EmptyTypeId; constructor(notifyProducer: Deferred); } export declare const EmitTypeId: unique symbol; export type EmitTypeId = typeof EmitTypeId; export declare class StateEmit { readonly notifyConsumers: ImmutableQueue>>; readonly _typeId: EmitTypeId; constructor(notifyConsumers: ImmutableQueue>>); } /** * An MVar-like abstraction for sending data to channels asynchronously. * Designed for one producer and multiple consumers. * * Features the following semantics: * - Buffer of size 1. * - When emitting, the producer waits for a consumer to pick up the value to * prevent "reading ahead" too much. * - Once an emitted element is read by a consumer, it is cleared from the * buffer, so that at most one consumer sees every emitted element. * - When sending a done or error signal, the producer does not wait for a * consumer to pick up the signal. The signal stays in the buffer after * being read by a consumer, so it can be propagated to multiple consumers. * - Trying to publish another emit/error/done after an error/done have * already been published results in an interruption. * * @tsplus type effect/core/stream/Channel/SingleProducerAsyncInput * @tsplus companion effect/core/stream/Channel/SingleProducerAsyncInput.Ops */ export declare class SingleProducerAsyncInput implements AsyncInputProducer, AsyncInputConsumer { readonly ref: Ref>; constructor(ref: Ref>); get take(): Effect, Elem>>; get close(): Effect; get awaitRead(): Effect; emit(el: Elem): Effect; done(a: Done): Effect; error(cause: Cause): Effect; takeWith(onError: (cause: Cause) => X, onElement: (element: Elem) => X, onDone: (done: Done) => X): Effect; } /** * Creates a `SingleProducerAsyncInput`. * @tsplus static effect/core/stream/Channel/SingleProducerAsyncInput.Ops make * @tsplus location "@effect/core/stream/Channel/SingleProducerAsyncInput" */ export declare function make(): Effect>; //# sourceMappingURL=SingleProducerAsyncInput.d.ts.map