import { Disposable } from 'vscode-jsonrpc';
import { CancellationToken } from './cancellation';
/**
 * Semaphore-like object that allows multiple awaiters to coordinate exclusive access to a resource.
 */
export declare class Semaphore implements Disposable {
    private count;
    private readonly completions;
    private disposed;
    /**
     * Creates a new semaphore instance.
     * @param initialCount Optional initial count. Defaults to 0.
     */
    constructor(initialCount?: number);
    /**
     * Gets the current available count of the semaphore.
     */
    get currentCount(): number;
    /**
     * Releases the semaphore, increasing the available count or unblicking one or more awaiters.
     * @param releaseCount Optional specified count to release. Defaults to 1.
     * @returns The previous count (before release).
     */
    release(releaseCount?: number): number;
    /**
     * Releases the semaphore, but does not throw an `ObjectDisposedError` if it is already disposed.
     */
    tryRelease(): void;
    /**
     * Waits until the semaphore is available. If the current count is greater than zero, this
     * decreases the available count by one and returns immediately.
     * @param cancellation Optional cancellation token that cancels the wait.
     * @throws CancellationError if the cancellation token is cancelled before the wait completes.
     */
    wait(cancellation?: CancellationToken): Promise<void>;
    /**
     * Waits until the semaphore is available or until a timeout expires. If the current count is
     * greater than zero, this decreases the available count by one and returns immediately.
     * @param millisecondsTimeout Optional timeout in milliseconds.
     * @param cancellation Optional cancellation token that cancels the wait.
     * @returns True if the wait succeeded, false if the timeout expired.
     * @throws CancellationError if the cancellation token is cancelled before the wait completes
     * or the timeout expires.
     */
    wait(millisecondsTimeout?: number, cancellation?: CancellationToken): Promise<boolean>;
    /**
     * Disposes the semaphore and throws a diposed error to any awaiters.
     */
    dispose(): void;
}
//# sourceMappingURL=semaphore.d.ts.map