Class: MappedLock

utils.MappedLock

new MappedLock()

Represents a mutex lock for locking asynchronous object methods. Locks methods according to passed-in key.

Source:

Methods

(static) create() → {function}

Create a closure scoped lock.

Source:
Returns:

Lock method.

Type
function

destroy()

Destroy the lock. Purge all pending calls.

Source:

has(name) → {Boolean}

Test whether the lock has a pending job or a job in progress (by name).

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Boolean

hasPending(name) → {Boolean}

Test whether the lock has a pending job by name.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Boolean

lock(key, forcenullable) → {Promise}

Lock the parent object and all its methods which use the lock with a specified key. Begin to queue calls.

Parameters:
Name Type Attributes Description
key String | Number
force Boolean <nullable>

Force a call.

Source:
Returns:
  • Returns {Function}, must be called once the method finishes executing in order to resolve the queue.
Type
Promise

(private) unlock(key) → {function}

Create an unlock callback.

Parameters:
Name Type Description
key String
Source:
Returns:

Unlocker.

Type
function