import { Barrier } from './Barrier';
/**
 * Implements a simple semaphore for async code logic.
 *
 * The implementation is adopted from `@dr.pogodin/react-utils`, with private
 * fields replaced by underscore-prefixed public fields to avoid issues with
 * React Native, for which see:
 * https://github.com/birdofpreyru/react-native-static-server/issues/6
 * https://github.com/birdofpreyru/react-native-static-server/issues/9
 *
 * Docs: https://dr.pogodin.studio/docs/react-utils/docs/api/classes/Semaphore
 */
export default class Semaphore {
    constructor(ready: boolean);
    get ready(): boolean;
    setReady(ready: boolean): void;
    /**
     * Waits until the semaphore is ready, and marks it as non-ready (seizes it).
     * @return {Promise}
     */
    seize(): Promise<void>;
    waitReady(seize?: boolean): Promise<void>;
    /**
     * If semaphore is ready, it releases the next barrier in the queue, if any,
     * and reschedules itself for a call in the next event loop iteration.
     * Otherwise, it breaks the queue draining loop, which will be restarted
     * the next time the semaphore is set ready.
     */
    _drainQueue(): Promise<void>;
    _draining: boolean;
    _drainLock: Barrier<void> | null;
    _queue: Barrier<void>[];
    _ready: boolean;
}
//# sourceMappingURL=Semaphore.d.ts.map