/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Licensed under the Apache License, Version 2.0.

See LICENSE file in the project root for details.
***************************************************************************** */
import { CancellationToken } from "./cancellation";
import { Cancelable } from "@esfx/cancelable";
/**
 * Enables multiple tasks to cooperatively work on an algorithm through
 * multiple phases.
 */
export declare class Barrier {
    private _isExecutingPostPhaseAction;
    private _postPhaseAction;
    private _phaseNumber;
    private _participantCount;
    private _remainingParticipants;
    private _waiters;
    /**
     * Initializes a new instance of the Barrier class.
     *
     * @param participantCount The initial number of participants for the barrier.
     * @param postPhaseAction An action to execute between each phase.
     */
    constructor(participantCount: number, postPhaseAction?: (barrier: Barrier) => void | PromiseLike<void>);
    /**
     * Gets the number of the Barrier's current phase.
     */
    get currentPhaseNumber(): number;
    /**
     * Gets the total number of participants in the barrier.
     */
    get participantCount(): number;
    /**
     * Gets the number of participants in the barrier that haven't yet signaled in the current phase.
     */
    get remainingParticipants(): number;
    /**
     * Notifies the Barrier there will be additional participants.
     *
     * @param participantCount The number of additional participants.
     */
    add(participantCount?: number): void;
    /**
     * Notifies the Barrier there will be fewer participants.
     *
     * @param participantCount The number of participants to remove.
     */
    remove(participantCount?: number): void;
    /**
     * Signals that a participant has reached the barrier and waits for all other participants
     * to reach the barrier.
     *
     * @param token An optional CancellationToken used to cancel the request.
     */
    signalAndWait(token?: CancellationToken | Cancelable): Promise<void>;
    private _finishPhase;
    private _nextPhase;
    private _resolveNextPhase;
    private _rejectNextPhase;
}
