Mutex Class

    Package: @esfx/threading-mutex
    Declaration
    export declare class Mutex implements Lockable, Disposable 

    Constructors

    constructor(initiallyOwned)

    Constructs a new instance of the Mutex class

    Declaration
    constructor(initiallyOwned?: boolean);
    Parameters
    initiallyOwned
    boolean

    constructor(buffer, byteOffset)

    Constructs a new instance of the Mutex class

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

    byteOffset
    number

    Properties

    buffer

    Gets the SharedArrayBuffer for this mutex.

    Declaration
    get buffer(): SharedArrayBuffer;
    Property Value
    SharedArrayBuffer

    byteLength

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

    Declaration
    get byteLength(): number;
    Property Value
    number

    byteOffset

    Gets the byte offset of this mutex in its buffer.

    Declaration
    get byteOffset(): number;
    Property Value
    number

    isLocked

    Gets a value indicating whether the mutex is currently locked.

    Declaration
    get isLocked(): boolean;
    Property Value
    boolean

    ownsLock

    Gets a value indicating whether this instance of the mutex owns the lock.

    Declaration
    get ownsLock(): boolean;
    Property Value
    boolean

    SIZE

    Declaration
    static readonly SIZE = 4;

    Methods

    [Disposable.dispose]()

    Releases the lock on the mutex (if this mutex owns the lock) and releases all resources for this mutex.

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

    [Lockable.lock](ms)

    Declaration
    [Lockable.lock](ms?: number): boolean;
    Parameters
    ms
    number

    Returns
    boolean

    [Lockable.tryLock]()

    Declaration
    [Lockable.tryLock](): boolean;
    Returns
    boolean

    [Lockable.unlock]()

    Declaration
    [Lockable.unlock](): boolean;
    Returns
    boolean

    close()

    Releases the lock on the mutex (if this mutex owns the lock) and releases all resources for this mutex.

    Declaration
    close(): void;
    Returns
    void

    lock(ms)

    Blocks the current Agent until it can acquire a lock on the mutex.

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

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

    Returns
    boolean

    true if the lock was acquired within the provided timeout period; otherwise, false.

    tryLock()

    Attempts to acquire a lock on the mutex without blocking the current Agent.

    Declaration
    tryLock(): boolean;
    Returns
    boolean

    true if the lock was acquired successfully; otherwise, false.

    unlock()

    Releases the lock on the mutex allowing the next waiter to take the lock.

    Declaration
    unlock(): boolean;
    Returns
    boolean

    true if the lock was released successfully; otherwise, false.

    Generated by DocFX