Interface ExpiringReadWriteLocker

A ReadWriteLocker where the locks expire after a given time.

interface ExpiringReadWriteLocker {
    withReadLock: (<T>(identifier: ResourceIdentifier, whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)) => Promise<T>);
    withWriteLock: (<T>(identifier: ResourceIdentifier, whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)) => Promise<T>);
}

Hierarchy (view full)

Implemented by

Properties

withReadLock: (<T>(identifier: ResourceIdentifier, whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)) => Promise<T>)

As ReadWriteLocker.withReadLock but the locked function gets called with a maintainLock callback function to reset the lock expiration every time it is called. The resulting promise will reject once the lock expires.

Type declaration

    • <T>(identifier, whileLocked): Promise<T>
    • Type Parameters

      • T

      Parameters

      • identifier: ResourceIdentifier

        Identifier of the resource that needs to be locked.

      • whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)

        A function to execute while the resource is locked. Receives a callback as input parameter to maintain the lock.

      Returns Promise<T>

withWriteLock: (<T>(identifier: ResourceIdentifier, whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)) => Promise<T>)

As ReadWriteLocker.withWriteLock but the locked function gets called with a maintainLock callback function to reset the lock expiration every time it is called. The resulting promise will reject once the lock expires.

Type declaration

    • <T>(identifier, whileLocked): Promise<T>
    • Type Parameters

      • T

      Parameters

      • identifier: ResourceIdentifier

        Identifier of the resource that needs to be locked.

      • whileLocked: ((maintainLock: (() => void)) => PromiseOrValue<T>)

        A function to execute while the resource is locked. Receives a callback as input parameter to maintain the lock.

      Returns Promise<T>