use of teetime.framework.InstantiationPipe in project TeeTime by teetime-framework.
the class A3PipeInstantiation method instantiatePipe.
private <T> void instantiatePipe(final IPipe<T> pipe) {
IPipe<T> instantiatedPipe;
AbstractStage sourceStage = pipe.getSourcePort().getOwningStage();
AbstractStage targetStage = pipe.getTargetPort().getOwningStage();
if (!(pipe instanceof InstantiationPipe)) {
// if manually connected
instantiatedPipe = pipe;
} else if (!targetStage.isActive() || sourceStage == targetStage) {
// NOPMD .equals() can't be used here
// normal or reflexive pipe => intra
instantiatedPipe = new UnsynchedPipe<T>(pipe.getSourcePort(), pipe.getTargetPort());
LOGGER.debug("Connected (unsynch) {} and {}", pipe.getSourcePort(), pipe.getTargetPort());
} else if (pipe.capacity() == 0) {
// synchronized, unlimited capacity
instantiatedPipe = new UnboundedSynchedPipe<T>(pipe.getSourcePort(), pipe.getTargetPort());
LOGGER.debug("Connected (unbounded) {} and {}", pipe.getSourcePort(), pipe.getTargetPort());
} else {
// synchronized, limited capacity
instantiatedPipe = new BoundedSynchedPipe<T>(pipe.getSourcePort(), pipe.getTargetPort(), pipe.capacity());
LOGGER.debug("Connected (bounded) {} and {}", pipe.getSourcePort(), pipe.getTargetPort());
}
instantiatedPipe.setScheduler(this);
}
Aggregations