Class: Lock

utils.Lock

new Lock(namednullable)

Represents a mutex lock for locking asynchronous object methods.

Parameters:
Name Type Attributes Description
named Boolean <nullable>

Whether to maintain a map of queued jobs by job name.

Source:

Methods

(static) create(namednullable) → {function}

Create a closure scoped lock.

Parameters:
Name Type Attributes Description
named Boolean <nullable>
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(namenullable, forcenullable) → {Promise}

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

Parameters:
Name Type Attributes Description
name String <nullable>

Job name.

force Boolean <nullable>

Bypass the lock.

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

(private) unlock()

The actual unlock callback.

Source: