fix Ox.queue cancel + clear

This commit is contained in:
rolux 2013-11-20 00:55:08 +01:00
parent 215c364182
commit e1134f2f4c

View file

@ -105,10 +105,12 @@ Ox.queue = function(fn, maxThreads) {
}, {async: true, key: getKey}), }, {async: true, key: getKey}),
threads = 0; threads = 0;
ret.cancel = function() { ret.cancel = function() {
threads -= processing.length;
processing = []; processing = [];
return ret; return ret;
}; };
ret.clear = function() { ret.clear = function() {
threads = 0;
queued = []; queued = [];
return ret; return ret;
}; };
@ -134,8 +136,8 @@ Ox.queue = function(fn, maxThreads) {
if (index > -1) { if (index > -1) {
processing.splice(index, 1); processing.splice(index, 1);
args.slice(-1)[0](result); args.slice(-1)[0](result);
threads--;
} }
threads--;
callback(); callback();
})); }));
}, },