Class Lockable

This base class provides an lock interface to execute exclusive operations

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

isLocked: boolean
readyPromise: Promise<Lockable>

Accessors

  • get isReady(): boolean
  • Indicates if there is currently no exclusive operation executed true If no exclusive lock is hold

    Returns boolean

Methods

  • Waits on the previously requested operation and calls the doneCallback if the operation is fulfilled

    Returns

    A promise which completes successfully, when the previously requested operation completes

    Parameters

    • Optional doneCallback: ((this: Lockable) => any)

      The callback which will be invoked when the previously operations on this object is completed.

    • Optional failCallback: ((error: Error) => any)

      When the lock can't be released caused by a none recoverable error

        • (error: Error): any
        • Parameters

          • error: Error

          Returns any

    Returns Promise<Lockable>

  • Protected

    Try to aquire an exclusive lock and executes the given callback.

    Returns

    A promise

    Throws

    If the lock can't be aquired

    Type Parameters

    • T

    Parameters

    • callback: (() => Promise<T>)

      The exclusive operation to execute

        • (): Promise<T>
        • Returns Promise<T>

    • Optional critical: boolean = false

      Indicates if the operation is critical. If the operation is critical and the operation fails, then the lock will not be released

    Returns Promise<T>

Generated using TypeDoc