Skip to content

Commit

Permalink
Merge pull request #62 from jdanford/fix-acquire-max-pending
Browse files Browse the repository at this point in the history
Use `maxPending` value from options in `acquire()` method
  • Loading branch information
rogierschouten authored Dec 22, 2023
2 parents cf98f50 + 59f7864 commit 66b98e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ AsyncLock.prototype.acquire = function (key, fn, cb, opts) {
exec = process.domain.bind(exec);
}

var maxPending = opts.maxPending || self.maxPending;

if (!self.queues[key]) {
self.queues[key] = [];
exec(true);
Expand All @@ -191,7 +193,7 @@ AsyncLock.prototype.acquire = function (key, fn, cb, opts) {
// Since lock is re-enterable
exec(false);
}
else if (self.queues[key].length >= self.maxPending) {
else if (self.queues[key].length >= maxPending) {
done(false, new Error('Too many pending tasks in queue ' + key));
}
else {
Expand Down

0 comments on commit 66b98e1

Please sign in to comment.