import { IDisposable } from "./disposable"; /** * The response from a barrier. If the barrier is disposed, the status is "disposed". * If the barrier is opened, the status is "resolved" and the value is the value passed to open(). * This is used instead of rejecting a barrier promise so that error state is explicitly handled. */ export type BarrierResponse = { status: "disposed"; } | { status: "resolved"; value: T; }; /** * A barrier that is initially closed and then becomes opened permanently. * You can wait for the barrier to open, but you cannot close it again. */ export declare class Barrier implements IDisposable { protected _isOpen: boolean; protected _promise: Promise>; protected _completePromise: (v: BarrierResponse) => void; constructor(); /** * Returns true if the barrier is open, false if it is closed * @returns true if the barrier is open, false if it is closed */ isOpen(): boolean; /** * Opens the barrier. If the barrier is already open, this method does nothing. * @param value the value to return when the barrier is opened * @returns */ open(value: T): void; /** * * @returns a promise that resolves when the barrier is opened. If the barrier is already open, the promise resolves immediately. */ wait(): Promise>; /** * DO NOT USE THIS METHOD in production code. This is only for tests. * This is a convenience method that waits for the barrier to open and then returns the value. * If the Barrier is disposed while waiting to open, an error is thrown. * @returns the value if the barrier is open, otherwise throws an error */ __waitAndThrowIfDisposed(): Promise; /** * Disposes the barrier. * If there is a promise waiting for the barrier to open, it will be resolved with a status of "disposed". */ dispose(): void; } /** * Like Barrier, but you can close the barrier again */ export declare class ClosableBarrier extends Barrier { close(): void; }