diff options
-rw-r--r-- | tools/queue.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/queue.js b/tools/queue.js index ebe17cd..cbd515b 100644 --- a/tools/queue.js +++ b/tools/queue.js @@ -2,7 +2,7 @@ module.exports = function(delayms, maxExport, call){ let queue = []; - let open = true; + let open = true; // The meaning of this variable is complicated, so watch closely let getObjs = (maxExport == 1) ? () => queue.shift() : () => queue.splice(0, maxExport) ; @@ -12,7 +12,19 @@ module.exports = function(delayms, maxExport, call){ if (open) dequeue(); } + disabled = true; // Used to disable pushes when non-sensical like if a socket is down + this.disable = function(){ + disabled = true; + } + this.enable = function(){ + disabled = false; + if (open) dequeue(); + } function dequeue(){ + if (disabled){ + open = true; + return; + } if (queue.length == 0) open = true; else { |