From 5a353d159274d5ff8a5e56318d09d647b49717ff Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 10 Oct 2016 00:40:42 -0700 Subject: [PATCH] locker: refactor. --- lib/utils/locker.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/utils/locker.js b/lib/utils/locker.js index f9c3c073..f4011e12 100644 --- a/lib/utils/locker.js +++ b/lib/utils/locker.js @@ -73,10 +73,10 @@ Locker.prototype.hasPending = function hasPending(key) { Locker.prototype.lock = function lock(arg1, arg2) { var self = this; - var force, object; + var force, item; if (this.add) { - object = arg1; + item = arg1; force = arg2; } else { force = arg1; @@ -91,13 +91,13 @@ Locker.prototype.lock = function lock(arg1, arg2) { } if (this.busy) { - if (object) { - this.pending.push(object); - this.pendingMap[object.hash('hex')] = true; + if (item) { + this.pending.push(item); + this.pendingMap[item.hash('hex')] = true; } return new Promise(function(resolve, reject) { - self.jobs.push(new Job(resolve, reject, object)); + self.jobs.push(new Job(resolve, reject, item)); }); } @@ -125,13 +125,13 @@ Locker.prototype.unlock = function unlock() { job = this.jobs.shift(); if (this.destroyed) { - job.reject(new Error('Locker is destroyed.')); + job.reject(new Error('Locker was destroyed.')); return; } - if (job.object) { - assert(job.object === this.pending.shift()); - delete this.pendingMap[job.object.hash('hex')]; + if (job.item) { + assert(job.item === this.pending.shift()); + delete this.pendingMap[job.item.hash('hex')]; } this.busy = true; @@ -258,7 +258,7 @@ MappedLock.prototype.unlock = function unlock(key) { delete self.jobs[key]; if (self.destroyed) { - job.reject(new Error('Locker is destroyed.')); + job.reject(new Error('Locker was destroyed.')); return; } @@ -282,13 +282,13 @@ MappedLock.prototype.destroy = function destroy() { * @constructor * @param {Function} resolve * @param {Function} reject - * @param {Object?} object + * @param {Object?} item */ -function Job(resolve, reject, object) { +function Job(resolve, reject, item) { this.resolve = resolve; this.reject = reject; - this.object = object || null; + this.item = item || null; } /*