summaryrefslogtreecommitdiff
path: root/mocha_test
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2016-07-12 12:48:28 -0700
committerGitHub <noreply@github.com>2016-07-12 12:48:28 -0700
commita46e3b788d4d4b5bb0efb7df39fc662053b6c87f (patch)
tree549cc3a8d980d162736284b0afe921b9699e6df9 /mocha_test
parent4794563888a7715ac49d87586de82867b538abde (diff)
parent3991202f6c6d90a624808c7ffdcabbceae0cd7cd (diff)
downloadasync-a46e3b788d4d4b5bb0efb7df39fc662053b6c87f.tar.gz
Merge pull request #1230 from suguru03/fix-priority-queue
fix execution order
Diffstat (limited to 'mocha_test')
-rw-r--r--mocha_test/priorityQueue.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/mocha_test/priorityQueue.js b/mocha_test/priorityQueue.js
index b777815..f71e665 100644
--- a/mocha_test/priorityQueue.js
+++ b/mocha_test/priorityQueue.js
@@ -108,6 +108,35 @@ describe('priorityQueue', function() {
};
});
+ it('pause in worker with concurrency', function(done) {
+ var call_order = [];
+ var q = async.priorityQueue(function (task, callback) {
+ if (task.isLongRunning) {
+ q.pause();
+ setTimeout(function () {
+ call_order.push(task.id);
+ q.resume();
+ callback();
+ }, 50);
+ }
+ else {
+ call_order.push(task.id);
+ setTimeout(callback, 10);
+ }
+ }, 10);
+
+ q.push({ id: 1, isLongRunning: true});
+ q.push({ id: 2 });
+ q.push({ id: 3 });
+ q.push({ id: 4 });
+ q.push({ id: 5 });
+
+ q.drain = function () {
+ expect(call_order).to.eql([1, 2, 3, 4, 5]);
+ done();
+ };
+ });
+
context('q.saturated(): ', function() {
it('should call the saturated callback if tasks length is concurrency', function(done) {
var calls = [];