use of teetime.framework.AbstractStage in project TeeTime by teetime-framework.
the class A2InvalidThreadAssignmentCheck method check.
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void check() {
int color = DEFAULT_COLOR;
ObjectIntMap<AbstractStage> colors = new ObjectIntHashMap<AbstractStage>();
ThreadPainter threadPainter = new ThreadPainter();
Traverser traverser = new Traverser(threadPainter);
for (AbstractStage threadableStage : threadableStages) {
color++;
colors.put(threadableStage, color);
threadPainter.reset(colors, color, threadableStages);
traverser.traverse(threadableStage);
}
}
use of teetime.framework.AbstractStage in project TeeTime by teetime-framework.
the class A2LevelIndexVisitor method visit.
@Override
public VisitorBehavior visit(final AbstractPort<?> port) {
AbstractStage sourceStage = port.getOwningStage();
AbstractStage targetStage = port.getPipe().getTargetPort().getOwningStage();
int targetLevelIndex = STAGE_FACADE.getLevelIndex(targetStage);
int sourceLevelIndex = STAGE_FACADE.getLevelIndex(sourceStage);
int levelIndex = Math.max(targetLevelIndex, sourceLevelIndex + 1);
STAGE_FACADE.setLevelIndex(targetStage, levelIndex);
maxLevelIndex = Math.max(maxLevelIndex, levelIndex);
return VisitorBehavior.CONTINUE_FORWARD;
}
use of teetime.framework.AbstractStage in project TeeTime by teetime-framework.
the class ScheduleQueue method scheduleStages.
/**
* @param stages
* to be scheduled
* @return <code>true</code> iff all of the given stages could be scheduled, otherwise <code>false</code>.
*/
default boolean scheduleStages(final Collection<? extends AbstractStage> stages) {
boolean scheduledAllStages = true;
for (AbstractStage stage : stages) {
boolean scheduledStage = scheduleStage(stage);
scheduledAllStages = scheduledAllStages && scheduledStage;
}
return scheduledAllStages;
}
use of teetime.framework.AbstractStage 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);
}
use of teetime.framework.AbstractStage in project TeeTime by teetime-framework.
the class NextActiveStageShouldTerminate method isMet.
@Override
public boolean isMet() {
// traverse at runtime (!) until another active (consumer) stage was found
Traverser traverser = new Traverser(visitor, alwaysFalseCondition);
traverser.traverse(stage);
InputPort<?> inputPortOfActiveStage = visitor.getActiveConsumerStageInputPort();
AbstractStage activeStage = inputPortOfActiveStage.getOwningStage();
for (InputPort<?> inputPort : StageFacade.INSTANCE.getInputPorts(activeStage)) {
if (inputPort != inputPortOfActiveStage && !inputPort.isClosed()) {
return false;
}
}
return true;
}
Aggregations