Search in sources :

Example 16 with AbstractStage

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);
    }
}
Also used : ObjectIntHashMap(com.carrotsearch.hppc.ObjectIntHashMap) Traverser(teetime.framework.Traverser) AbstractStage(teetime.framework.AbstractStage)

Example 17 with AbstractStage

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;
}
Also used : AbstractStage(teetime.framework.AbstractStage)

Example 18 with AbstractStage

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;
}
Also used : AbstractStage(teetime.framework.AbstractStage)

Example 19 with AbstractStage

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);
}
Also used : InstantiationPipe(teetime.framework.InstantiationPipe) AbstractStage(teetime.framework.AbstractStage)

Example 20 with AbstractStage

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;
}
Also used : Traverser(teetime.framework.Traverser) AbstractStage(teetime.framework.AbstractStage)

Aggregations

AbstractStage (teetime.framework.AbstractStage)23 Test (org.junit.Test)9 Traverser (teetime.framework.Traverser)3 StateChange (teetime.framework.performancelogging.StateChange)3 ObjectIntHashMap (com.carrotsearch.hppc.ObjectIntHashMap)1 Logger (org.slf4j.Logger)1 InstantiationPipe (teetime.framework.InstantiationPipe)1 TestConfiguration (teetime.framework.TestConfiguration)1 StageActivationState (teetime.framework.performancelogging.StateChange.StageActivationState)1 CollectorSink (teetime.stage.CollectorSink)1 InitialElementProducer (teetime.stage.InitialElementProducer)1 CreatePortActionDistributor (teetime.stage.basic.distributor.dynamic.CreatePortActionDistributor)1 CreatePortActionMerger (teetime.stage.basic.merger.dynamic.CreatePortActionMerger)1