summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolan McMahon <caolan.mcmahon@gmail.com>2014-04-07 10:06:18 +0100
committerCaolan McMahon <caolan.mcmahon@gmail.com>2014-04-07 10:06:18 +0100
commit534a7ba6affb7ea5b81b9593c8b216554ae7436a (patch)
tree1a72c2ad1f0b536003341ea7105eceb943b75b31
parentdfa3c93bdf7bd41ea81a8af7a54bc523fad66009 (diff)
parent7fc85d7bb1bb252a58cf123c4a2f75ef33cee60b (diff)
downloadasync-534a7ba6affb7ea5b81b9593c8b216554ae7436a.tar.gz
Merge pull request #497 from jonmorehouse/master
Add in started attribute for queue
-rw-r--r--README.md3
-rwxr-xr-xlib/async.js4
-rwxr-xr-xtest/test-async.js13
3 files changed, 19 insertions, 1 deletions
diff --git a/README.md b/README.md
index 53dedba..1835942 100644
--- a/README.md
+++ b/README.md
@@ -918,7 +918,7 @@ async.waterfall([
callback(null, 'one', 'two');
},
function(arg1, arg2, callback){
- // arg1 now equals 'one' and arg2 now equals 'two'
+ // arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
},
function(arg1, callback){
@@ -1076,6 +1076,7 @@ The `queue` object returned by this function has the following properties and
methods:
* `length()` - a function returning the number of items waiting to be processed.
+* `started` - a function returning whether or not any items have been pushed and processed by the queue
* `running()` - a function returning the number of items currently being processed.
* `idle()` - a function returning false if there are items waiting or being processed, or true if not.
* `concurrency` - an integer for determining how many `worker` functions should be
diff --git a/lib/async.js b/lib/async.js
index a5ffffa..20afb3b 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -721,6 +721,9 @@
concurrency = 1;
}
function _insert(q, data, pos, callback) {
+ if (!q.started){
+ q.started = true;
+ }
if (!_isArray(data)) {
data = [data];
}
@@ -758,6 +761,7 @@
saturated: null,
empty: null,
drain: null,
+ started: false,
paused: false,
push: function (data, callback) {
_insert(q, data, false, callback);
diff --git a/test/test-async.js b/test/test-async.js
index 6d65c15..d9f2dee 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2913,3 +2913,16 @@ exports['queue empty'] = function(test) {
};
q.push([]);
};
+
+exports['queue started'] = function(test) {
+
+ var calls = [];
+ var q = async.queue(function(task, cb) {});
+
+ test.equal(q.started, false);
+ q.push([]);
+ test.equal(q.started, true);
+ test.done();
+
+};
+