package javaflow.network.impl;
import javaflow.components.api.Packet;
final class RunnableSubstreamSensitiveSubnetInput extends RunnableSubnetInput {
public RunnableSubstreamSensitiveSubnetInput(
String portName,
InputPortImpl inputPort,
OutputPortImpl outputPort,
SubnetComponent subnetComponent) {
super(portName, inputPort, outputPort, subnetComponent);
}
@Override
protected boolean shouldContinueRunning() {
return false;
}
@Override
public void execute() {
Packet packet;
int level = 0;
while((packet = inputPort.receive())!=null){
switch (packet.getType()){
case START:
packet.drop();
level++;
break;
case END:
packet.drop();
level--;
break;
case NORMAL:
outputPort.send(packet);
break;
}
if (level == 0){
outputPort.close();
return;
}
}
}
}