From 220fd99ffe9270b8d30e84b3d935ab0696f1a808 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Sun, 29 Dec 2019 20:01:32 -0500 Subject: added disabling to tools/queue --- tools/queue.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tools') 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 { -- cgit