import type { Either } from "../../Either"; import { ImmutableQueue } from "../../support"; import * as M from "../Managed/_core"; import * as T from "../Task/_core"; import type { XPromise } from "../XPromise"; import type { Ref } from "../XRef/model"; export declare type Entry = [XPromise, number]; export declare type State = Either, number>; export declare const assertNonNegative: (n: number) => T.IO; export declare class Acquisition { readonly waitAcquire: T.IO; readonly release: T.IO; constructor(waitAcquire: T.IO, release: T.IO); } /** * An asynchronous semaphore, which is a generalization of a mutex. Semaphores * have a certain number of permits, which can be held and released * concurrently by different parties. Attempts to acquire more permits than * available result in the acquiring fiber being suspended until the specified * number of permits become available. **/ export declare class Semaphore { private readonly state; constructor(state: Ref); get available(): T.Task; private loop; private releaseN; private restore; prepare(n: number): T.IO; } /** * Acquires `n` permits, executes the action and releases the permits right after. */ export declare const withPermits: (n: number) => (s: Semaphore) => (e: T.Task) => T.Task; /** * Acquires a permit, executes the action and releases the permit right after. */ export declare const withPermit: (s: Semaphore) => (e: T.Task) => T.Task; /** * Acquires `n` permits in a [[Managed]] and releases the permits in the finalizer. */ export declare const withPermitsManaged: (n: number) => (s: Semaphore) => M.Managed; /** * Acquires a permit in a [[Managed]] and releases the permit in the finalizer. */ export declare const withPermitManaged: (s: Semaphore) => M.Managed; /** * The number of permits currently available. */ export declare const available: (s: Semaphore) => T.Task; /** * Creates a new `Sempahore` with the specified number of permits. */ export declare const makeSemaphore: (permits: number) => T.Task; /** * Creates a new `Sempahore` with the specified number of permits. */ export declare const unsafeMakeSemaphore: (permits: number) => Semaphore; //# sourceMappingURL=model.d.ts.map