aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-29 20:01:32 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-29 20:01:32 -0500
commit220fd99ffe9270b8d30e84b3d935ab0696f1a808 (patch)
treec809ed5573f5dd68a6018a7b94e225899e0c593b
parent0bbbb39ce8ded2b3e6d5413511a48449a83dfd9c (diff)
added disabling to tools/queue
-rw-r--r--tools/queue.js14
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 {