/** * @since 1.0.0 */ import type { LazyArg } from "@effect/data/Function"; import type * as Option from "@effect/data/Option"; import type { Pipeable } from "@effect/data/Pipeable"; import type * as Cause from "@effect/io/Cause"; import type * as Effect from "@effect/io/Effect"; import type * as Exit from "@effect/io/Exit"; import type * as FiberId from "@effect/io/FiberId"; /** * @since 1.0.0 * @category symbols */ export declare const DeferredTypeId: unique symbol; /** * @since 1.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 1.0.0 * @category models */ export interface Deferred extends Deferred.Variance, Pipeable { } /** * @since 1.0.0 */ export declare namespace Deferred { /** * @since 1.0.0 * @category models */ interface Variance { readonly [DeferredTypeId]: { readonly _E: (_: never) => E; readonly _A: (_: never) => A; }; } } /** * Creates a new `Deferred`. * * @since 1.0.0 * @category constructors */ export declare const make: () => Effect.Effect>; /** * Creates a new `Deferred` from the specified `FiberId`. * * @since 1.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 1.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 1.0.0 * @category utils */ export declare const complete: { (effect: Effect.Effect): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const completeWith: { (effect: Effect.Effect): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const done: { (exit: Exit.Exit): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const fail: { (error: E): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const failSync: { (evaluate: LazyArg): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const failCause: { (cause: Cause.Cause): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const failCauseSync: { (evaluate: LazyArg>): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const die: { (defect: unknown): (self: Deferred) => Effect.Effect; (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 1.0.0 * @category utils */ export declare const dieSync: { (evaluate: LazyArg): (self: Deferred) => Effect.Effect; (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 1.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 1.0.0 * @category utils */ export declare const interruptWith: { (fiberId: FiberId.FiberId): (self: Deferred) => Effect.Effect; (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 1.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 1.0.0 * @category getters */ export declare const poll: (self: Deferred) => Effect.Effect>>; /** * Completes the `Deferred` with the specified value. * * @since 1.0.0 * @category utils */ export declare const succeed: { (value: A): (self: Deferred) => Effect.Effect; (self: Deferred, value: A): Effect.Effect; }; /** * Completes the `Deferred` with the specified lazily evaluated value. * * @since 1.0.0 * @category utils */ export declare const sync: { (evaluate: LazyArg): (self: Deferred) => Effect.Effect; (self: Deferred, evaluate: LazyArg): Effect.Effect; }; /** * Unsafely creates a new `Deferred` from the specified `FiberId`. * * @since 1.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 1.0.0 * @category unsafe */ export declare const unsafeDone: (self: Deferred, effect: Effect.Effect) => void; //# sourceMappingURL=Deferred.d.ts.map