Package javaflow.network.impl

Source Code of javaflow.network.impl.RunnableSubstreamSensitiveSubnetInput

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;
                }
            }
        }

}
TOP

Related Classes of javaflow.network.impl.RunnableSubstreamSensitiveSubnetInput

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.