Permalink
Browse files

queue: [pause] emit drain in nexttick

  • Loading branch information...
1 parent 49f3dc2 commit 6cd891c3b5b5a0b7c4615767fe0ddbaf2fd2b04a @logicalparadox logicalparadox committed Feb 15, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/queue.js
View
15 lib/queue.js
@@ -242,13 +242,26 @@ Queue.prototype.process = function () {
};
Queue.prototype.pause = function () {
+ var self = this;
+
+ nextTick(function () {
+ if (self._paused && self.workers === 0) {
+ invoke(self.drain)();
+ }
+ });
+
this._paused = true;
return this;
};
Queue.prototype.resume = function () {
+ var self = this;
+
+ nextTick(function () {
+ self.process();
+ });
+
this._paused = false;
- this.process();
return this;
};

0 comments on commit 6cd891c

Please sign in to comment.