B2G/gecko/services/sync/modules/util.js
/**
   * Wrap a function to call lock before calling the function then unlock.
   *
   * @usage MyObj._lock = Utils.lock;
   *        MyObj.foo = function() { this._lock(func)(); }
   */
Wrap a function to call lock before calling the function then unlock.
Wrap a function to call lock before calling the function then unlock .
function lock(label, func) {
    let thisArg = this;
    return function WrappedLock() {
      if (!thisArg.lock()) {
        throw "Could not acquire lock. Label: \"" + label + "\".";
      }
      try {
        return func.call(thisArg);
      }
      finally {
        thisArg.unlock();
      }
    };
  }
function lock ( label , func ) { let thisArg = this ; return function WrappedLock ( ) { if ( ! thisArg . lock ( ) ) { throw "Could not acquire lock. Label: \"" + label + "\"." ; } try { return func . call ( thisArg ) ; } finally { thisArg . unlock ( ) ; } } ; }
Wrap a function to call lock before calling the function then unlock.
Wrap a function to call lock before calling the function then unlock .