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) {
} }
} }
this.on("input", function(msg) { function processQ(queue) {
var msgQueue = node.msgQueue; var msg = queue[0];
function processQ() {
var msg = msgQueue[0];
processMsg(msg, function() { processMsg(msg, function() {
msgQueue.shift(); queue.shift();
if (msgQueue.length > 0) { if (queue.length > 0) {
processQ(); processQ(queue);
} }
}); });
} }
this.on("input", function(msg) {
var msgQueue = node.msgQueue;
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() {