import "../../../../Operator/index.js"; import * as Cause from "../../../../Cause/index.js"; import * as T from "../../../../Effect/index.js"; import * as E from "../../../../Either/index.js"; import * as Exit from "../../../../Exit/index.js"; import * as P from "../../../../Promise/index.js"; import * as Ref from "../../../../Ref/index.js"; import * as IQ from "../../../../Support/ImmutableQueue/index.js"; /** * Producer-side view of `SingleProducerAsyncInput` for variance purposes. */ export interface AsyncInputProducer { emit(el: Elem): T.UIO; done(a: Done): T.UIO; error(cause: Cause.Cause): T.UIO; awaitRead: T.UIO; } /** * Consumer-side view of `SingleProducerAsyncInput` for variance purposes. */ export interface AsyncInputConsumer { takeWith(onError: (cause: Cause.Cause) => A, onElement: (element: Elem) => A, onDone: (done: Done) => A): T.UIO; } export declare const DoneTypeId: unique symbol; export declare type DoneTypeId = typeof DoneTypeId; export declare class StateDone { readonly a: Elem; readonly _typeId: DoneTypeId; constructor(a: Elem); } export declare const ErrorTypeId: unique symbol; export declare type ErrorTypeId = typeof ErrorTypeId; export declare class StateError { readonly cause: Cause.Cause; readonly _typeId: ErrorTypeId; constructor(cause: Cause.Cause); } export declare const EmptyTypeId: unique symbol; export declare type EmptyTypeId = typeof EmptyTypeId; export declare class StateEmpty { readonly notifyProducer: P.Promise; readonly _typeId: EmptyTypeId; constructor(notifyProducer: P.Promise); } export declare const EmitTypeId: unique symbol; export declare type EmitTypeId = typeof EmitTypeId; export declare class StateEmit { readonly notifyConsumers: IQ.ImmutableQueue>>; readonly _typeId: EmitTypeId; constructor(notifyConsumers: IQ.ImmutableQueue>>); } export declare type State = StateEmpty | StateEmit | StateError | StateDone; /** * 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. */ export declare class SingleProducerAsyncInput implements AsyncInputProducer, AsyncInputConsumer { readonly ref: Ref.Ref>; constructor(ref: Ref.Ref>); emit(el: Elem): T.UIO; done(a: Done): T.UIO; error(cause: Cause.Cause): T.UIO; takeWith(onError: (cause: Cause.Cause) => X, onElement: (element: Elem) => X, onDone: (done: Done) => X): T.UIO; take: T.UIO, Elem>>; close: T.Effect; awaitRead: T.Effect; } /** * Creates a SingleProducerAsyncInput */ export declare function makeSingleProducerAsyncInput(): T.UIO>; //# sourceMappingURL=producer.d.ts.map