noflo icon indicating copy to clipboard operation
noflo copied to clipboard

noflo assumes all control ports are populated before non-control ports when triggering process function

Open sfescape opened this issue 7 years ago • 6 comments

With a component such as:

component.Inport.add("in", { datatype: "all" }) component.Inport.add("ctl", { datatype: "object", control: true, required: true })

If you receive more then one packet at "in" before you receive any packet at "ctl" then once a "ctl" packet is received the process method is only triggered once, leaving the "in" buffer with unprocessed packets.

sfescape avatar Jul 30 '18 18:07 sfescape

That's actually expected behaviour. In order to get all packets from the buffer you need to use input.hasStream() and input.getStream(), or a loop over items using input.has() and input.get().

trustmaster avatar Nov 02 '18 15:11 trustmaster

Why would that be expected behavior? It only occurs in the case of control packets, and means your component has to be aware that there are control packets. What benefit does that have?

sfescape avatar Nov 02 '18 15:11 sfescape

There is no benefit, it's a design tradeoff. Firing patterns in FBP are not always easy. There might be a corner case like this, and components have to take it in consideration.

trustmaster avatar Nov 02 '18 16:11 trustmaster

I don't see what the design tradeoff is. Having a component randomly fail to process all messages because of a race condition certainly seems like a defect to me, not a tradeoff.

sfescape avatar Nov 03 '18 00:11 sfescape

The thing is, control ports are non-firing (by design). But indeed, I agree that there should be the exception that they probably should fire if there is unprocessed input in the other ports

bergie avatar Nov 03 '18 19:11 bergie

Mea culpa, I forgot that control ports in NoFlo don't fire. Then, indeed, it makes sense to do what @bergie suggested.

trustmaster avatar Nov 03 '18 21:11 trustmaster