Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • asynclock

Index

Constructors

constructor

Properties

Static Readonly DEFAULT_MAX_OCCUPATION_TIME

DEFAULT_MAX_OCCUPATION_TIME: number

Static Readonly DEFAULT_MAX_PENDING

DEFAULT_MAX_PENDING: number

Static Readonly DEFAULT_TIMEOUT

DEFAULT_TIMEOUT: number

Methods

acquire

  • Lock on asynchronous code.

    example

    import AsyncLock = require('async-lock'); const lock = new AsyncLock();

    lock.acquire( key, () => { // return value or promise }, opts ).then(() => { // lock released });

    Type parameters

    • T

    Parameters

    • key: string | string[]

      resource key or keys to lock

    • fn: (() => T | PromiseLike<T>) | ((done: AsyncLockDoneCallback<T>) => any)

      function to execute

    • Optional opts: AsyncLockOptions

      options

    Returns Promise<T>

  • Lock on asynchronous code.

    example

    import AsyncLock = require('async-lock'); const lock = new AsyncLock();

    lock.acquire( key, (done) => { // async work done(err, ret); }, (err, ret) => { // lock released }, opts );

    Type parameters

    • T

    Parameters

    Returns void

isBusy

  • isBusy(key?: string): boolean
  • Whether there is any running or pending async function.

    Parameters

    • Optional key: string

    Returns boolean

Generated using TypeDoc