src/utils/lock.js
function Lock(named) {
  if (!(this instanceof Lock))
    return Lock.create(named);

  this.named = named === true;

  this.jobs = [];
  this.busy = false;
  this.destroyed = false;

  this.map = new Map();
  this.current = null;

  this.unlocker = this.unlock.bind(this);
}
function Lock(named) {
  if (!(this instanceof Lock))
    return Lock.create(named);

  this.named = named === true;

  this.jobs = [];
  this.busy = false;
  this.destroyed = false;

  this.map = new Map();
  this.current = null;

  this.unlocker = this.unlock.bind(this);
}
function Lock ( named ) { if ( ! ( this instanceof Lock ) ) return Lock . create ( named ) ; this . named = named === true ; this . jobs = [ ] ; this . busy = false ; this . destroyed = false ; this . map = new Map ( ) ; this . current = null ; this . unlocker = this . unlock . bind ( this ) ; }
Represents a mutex lock for locking asynchronous object methods.
@alias module:utils.Lock
@constructor
@param {Boolean?} named - Whether to
maintain a map of queued jobs by job name.
Represents a mutex lock for locking asynchronous object methods .