/** * @since 2.0.0 */ import type * as Cause from "./Cause.js"; import type * as Effect from "./Effect.js"; import type * as Exit from "./Exit.js"; import type * as FiberId from "./FiberId.js"; import type { LazyArg } from "./Function.js"; import type * as Option from "./Option.js"; import type * as Types from "./Types.js"; import type * as Unify from "./Unify.js"; /** * @since 2.0.0 * @category symbols */ export declare const DeferredTypeId: unique symbol; /** * @since 2.0.0 * @category symbols */ export type DeferredTypeId = typeof DeferredTypeId; /** * A `Deferred` represents an asynchronous variable that can be set exactly * once, with the ability for an arbitrary number of fibers to suspend (by * calling `Deferred.await`) and automatically resume when the variable is set. * * `Deferred` can be used for building primitive actions whose completions * require the coordinated action of multiple fibers, and for building * higher-level concurrent or asynchronous structures. * * @since 2.0.0 * @category models */ export interface Deferred extends Effect.Effect, Deferred.Variance { readonly [Unify.typeSymbol]?: unknown; readonly [Unify.unifySymbol]?: DeferredUnify; readonly [Unify.ignoreSymbol]?: DeferredUnifyIgnore; } /** * @category models * @since 3.8.0 */ export interface DeferredUnify extends Effect.EffectUnify { Deferred?: () => Extract>; } /** * @category models * @since 3.8.0 */ export interface DeferredUnifyIgnore extends Effect.EffectUnifyIgnore { Effect?: true; } /** * @since 2.0.0 */ export declare namespace Deferred { /** * @since 2.0.0 * @category models */ interface Variance { readonly [DeferredTypeId]: { readonly _A: Types.Invariant; readonly _E: Types.Invariant; }; } } /** * Creates a new `Deferred`. * * @since 2.0.0 * @category constructors */ export declare const make: () => Effect.Effect>; /** * Creates a new `Deferred` from the specified `FiberId`. * * @since 2.0.0 * @category constructors */ export declare const makeAs: (fiberId: FiberId.FiberId) => Effect.Effect>; declare const _await: (self: Deferred) => Effect.Effect; export { /** * Retrieves the value of the `Deferred`, suspending the fiber running the * workflow until the result is available. * * @since 2.0.0 * @category getters */ _await as await }; /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * Note that `Deferred.completeWith` will be much faster, so consider using * that if you do not need to memoize the result of the specified effect. * * @since 2.0.0 * @category utils */ export declare const complete: { /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * Note that `Deferred.completeWith` will be much faster, so consider using * that if you do not need to memoize the result of the specified effect. * * @since 2.0.0 * @category utils */ (effect: Effect.Effect): (self: Deferred) => Effect.Effect; /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * Note that `Deferred.completeWith` will be much faster, so consider using * that if you do not need to memoize the result of the specified effect. * * @since 2.0.0 * @category utils */ (self: Deferred, effect: Effect.Effect): Effect.Effect; }; /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * @since 2.0.0 * @category utils */ export declare const completeWith: { /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * @since 2.0.0 * @category utils */ (effect: Effect.Effect): (self: Deferred) => Effect.Effect; /** * Completes the deferred with the result of the specified effect. If the * deferred has already been completed, the method will produce false. * * @since 2.0.0 * @category utils */ (self: Deferred, effect: Effect.Effect): Effect.Effect; }; /** * Exits the `Deferred` with the specified `Exit` value, which will be * propagated to all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const done: { /** * Exits the `Deferred` with the specified `Exit` value, which will be * propagated to all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (exit: Exit.Exit): (self: Deferred) => Effect.Effect; /** * Exits the `Deferred` with the specified `Exit` value, which will be * propagated to all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, exit: Exit.Exit): Effect.Effect; }; /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const fail: { /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (error: E): (self: Deferred) => Effect.Effect; /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, error: E): Effect.Effect; }; /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const failSync: { /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (evaluate: LazyArg): (self: Deferred) => Effect.Effect; /** * Fails the `Deferred` with the specified error, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, evaluate: LazyArg): Effect.Effect; }; /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const failCause: { /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (cause: Cause.Cause): (self: Deferred) => Effect.Effect; /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, cause: Cause.Cause): Effect.Effect; }; /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const failCauseSync: { /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (evaluate: LazyArg>): (self: Deferred) => Effect.Effect; /** * Fails the `Deferred` with the specified `Cause`, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, evaluate: LazyArg>): Effect.Effect; }; /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const die: { /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (defect: unknown): (self: Deferred) => Effect.Effect; /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, defect: unknown): Effect.Effect; }; /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ export declare const dieSync: { /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (evaluate: LazyArg): (self: Deferred) => Effect.Effect; /** * Kills the `Deferred` with the specified defect, which will be propagated to * all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category utils */ (self: Deferred, evaluate: LazyArg): Effect.Effect; }; /** * Completes the `Deferred` with interruption. This will interrupt all fibers * waiting on the value of the `Deferred` with the `FiberId` of the fiber * calling this method. * * @since 2.0.0 * @category utils */ export declare const interrupt: (self: Deferred) => Effect.Effect; /** * Completes the `Deferred` with interruption. This will interrupt all fibers * waiting on the value of the `Deferred` with the specified `FiberId`. * * @since 2.0.0 * @category utils */ export declare const interruptWith: { /** * Completes the `Deferred` with interruption. This will interrupt all fibers * waiting on the value of the `Deferred` with the specified `FiberId`. * * @since 2.0.0 * @category utils */ (fiberId: FiberId.FiberId): (self: Deferred) => Effect.Effect; /** * Completes the `Deferred` with interruption. This will interrupt all fibers * waiting on the value of the `Deferred` with the specified `FiberId`. * * @since 2.0.0 * @category utils */ (self: Deferred, fiberId: FiberId.FiberId): Effect.Effect; }; /** * Returns `true` if this `Deferred` has already been completed with a value or * an error, `false` otherwise. * * @since 2.0.0 * @category getters */ export declare const isDone: (self: Deferred) => Effect.Effect; /** * Returns a `Some>` from the `Deferred` if this `Deferred` has * already been completed, `None` otherwise. * * @since 2.0.0 * @category getters */ export declare const poll: (self: Deferred) => Effect.Effect>>; /** * Completes the `Deferred` with the specified value. * * @since 2.0.0 * @category utils */ export declare const succeed: { /** * Completes the `Deferred` with the specified value. * * @since 2.0.0 * @category utils */ (value: A): (self: Deferred) => Effect.Effect; /** * Completes the `Deferred` with the specified value. * * @since 2.0.0 * @category utils */ (self: Deferred, value: A): Effect.Effect; }; /** * Completes the `Deferred` with the specified lazily evaluated value. * * @since 2.0.0 * @category utils */ export declare const sync: { /** * Completes the `Deferred` with the specified lazily evaluated value. * * @since 2.0.0 * @category utils */ (evaluate: LazyArg): (self: Deferred) => Effect.Effect; /** * Completes the `Deferred` with the specified lazily evaluated value. * * @since 2.0.0 * @category utils */ (self: Deferred, evaluate: LazyArg): Effect.Effect; }; /** * Unsafely creates a new `Deferred` from the specified `FiberId`. * * @since 2.0.0 * @category unsafe */ export declare const unsafeMake: (fiberId: FiberId.FiberId) => Deferred; /** * Unsafely exits the `Deferred` with the specified `Exit` value, which will be * propagated to all fibers waiting on the value of the `Deferred`. * * @since 2.0.0 * @category unsafe */ export declare const unsafeDone: (self: Deferred, effect: Effect.Effect) => void; //# sourceMappingURL=Deferred.d.ts.map