summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJustin York <justin@genealogysystems.com>2014-02-24 18:20:03 +0000
committerJustin York <justin@genealogysystems.com>2014-02-24 18:20:03 +0000
commit489c6c3208b24eb4568640237fa6de0a656eba64 (patch)
treeaa7ff0e9c05bcac25fa69fe991da010b0a667189 /lib
parent2d5bc3f5a6db2d699646e59a551355a21cd98637 (diff)
downloadasync-489c6c3208b24eb4568640237fa6de0a656eba64.tar.gz
only call cargo.drain once each time it's drained
Diffstat (limited to 'lib')
-rwxr-xr-xlib/async.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/async.js b/lib/async.js
index 1eebb15..dcbc511 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -751,6 +751,7 @@
saturated: null,
empty: null,
drain: null,
+ drained: true,
push: function (data, callback) {
if(data.constructor !== Array) {
data = [data];
@@ -760,6 +761,7 @@
data: task,
callback: typeof callback === 'function' ? callback : null
});
+ cargo.drained = false;
if (cargo.saturated && tasks.length === payload) {
cargo.saturated();
}
@@ -769,7 +771,8 @@
process: function process() {
if (working) return;
if (tasks.length === 0) {
- if(cargo.drain) cargo.drain();
+ if(cargo.drain && !cargo.drained) cargo.drain();
+ cargo.drained = true;
return;
}