Semaphore Class

    Package: @esfx/threading-semaphore
    Declaration
    export declare class Semaphore 

    Constructors

    constructor(initialCount, maxCount)

    Constructs a new instance of the Semaphore class

    Declaration
    constructor(initialCount: number, maxCount?: number);
    Parameters
    initialCount
    number

    maxCount
    number

    constructor(buffer, byteOffset)

    Constructs a new instance of the Semaphore class

    Declaration
    constructor(buffer: SharedArrayBuffer, byteOffset?: number);
    Parameters
    buffer
    SharedArrayBuffer

    byteOffset
    number

    Properties

    buffer

    Gets the SharedArrayBuffer for this object.

    Declaration
    get buffer(): SharedArrayBuffer;
    Property Value
    SharedArrayBuffer

    byteLength

    Gets the number of bytes occupied by this object in its buffer.

    Declaration
    get byteLength(): number;
    Property Value
    number

    byteOffset

    Gets the byte offset of this object in its buffer.

    Declaration
    get byteOffset(): number;
    Property Value
    number

    count

    Gets the number of remaining threads that can enter the semaphore.

    Declaration
    get count(): number;
    Property Value
    number

    SIZE

    Declaration
    static readonly SIZE = 16;

    Methods

    [Disposable.dispose]()

    Releases all resources for this object.

    Declaration
    [Disposable.dispose](): void;
    Returns
    void

    close()

    Releases all resources for this object.

    Declaration
    close(): void;
    Returns
    void

    release(count)

    Exits the semaphore the provided number of times.

    Declaration
    release(count?: number): number;
    Parameters
    count
    number

    The number of times to exit the semaphore (default: 1).

    Returns
    number

    The previous count of the semaphore.

    wait(ms)

    Blocks the current thread until it can enter the semaphore.

    Declaration
    wait(ms?: number): boolean;
    Parameters
    ms
    number

    The number of milliseconds to wait before the operation times out.

    Returns
    boolean

    true if the semaphore was entered before the timeout elapsed; otherwise, false.

    Generated by DocFX