1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

lift processQ function

This commit is contained in:
Hiroyasu Nishiyama 2018-09-21 23:02:45 +09:00
parent 1a226c4dc6
commit 61681bb1d6

View File

@ -153,22 +153,23 @@ module.exports = function(RED) {
} }
} }
function processQ(queue) {
var msg = queue[0];
processMsg(msg, function() {
queue.shift();
if (queue.length > 0) {
processQ(queue);
}
});
}
this.on("input", function(msg) { this.on("input", function(msg) {
var msgQueue = node.msgQueue; var msgQueue = node.msgQueue;
function processQ() {
var msg = msgQueue[0];
processMsg(msg, function() {
msgQueue.shift();
if (msgQueue.length > 0) {
processQ();
}
});
}
if (msgQueue.push(msg) > 1) { if (msgQueue.push(msg) > 1) {
// pending write exists // pending write exists
return; return;
} }
processQ(); processQ(msgQueue);
}); });
this.on('close', function() { this.on('close', function() {