summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Argasinski <argasinski.hubert@gmail.com>2017-07-09 17:06:45 -0400
committerHubert Argasinski <argasinski.hubert@gmail.com>2017-07-09 17:06:45 -0400
commit4e6375fd55ddd820357655468f3c201cccad866e (patch)
treec933b26a08b6d7e553bc71a8820abcf2ce35071d
parent529f7c911a78dc6dd74b161e1d765fa300115bd8 (diff)
downloadasync-batch-push-queue.tar.gz
prevent overwriting q.process from pausing the queuebatch-push-queue
-rw-r--r--lib/internal/queue.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/internal/queue.js b/lib/internal/queue.js
index b06f12e..4f57edb 100644
--- a/lib/internal/queue.js
+++ b/lib/internal/queue.js
@@ -18,8 +18,8 @@ export default function queue(worker, concurrency, payload) {
var _worker = wrapAsync(worker);
var numRunning = 0;
var workersList = [];
- var isWaitingForProcessing = false;
+ var processingScheduled = false;
function _insert(data, insertAtFront, callback) {
if (callback != null && typeof callback !== 'function') {
throw new Error('task callback must be a function');
@@ -48,9 +48,12 @@ export default function queue(worker, concurrency, payload) {
}
}
- if (!isWaitingForProcessing) {
- isWaitingForProcessing = true;
- setImmediate(q.process);
+ if (!processingScheduled) {
+ processingScheduled = true;
+ setImmediate(function() {
+ processingScheduled = false;
+ q.process();
+ });
}
}
@@ -111,8 +114,6 @@ export default function queue(worker, concurrency, payload) {
q._tasks.remove(testFn);
},
process: function () {
- isWaitingForProcessing = false;
-
// Avoid trying to start too many processing operations. This can occur
// when callbacks resolve synchronously (#1267).
if (isProcessing) {