if (next instanceof SIRJoiner && !(next.getParent() instanceof SIRFeedbackLoop)) { assert next.getParent() instanceof SIRSplitJoin; SIRJoiner joiner = (SIRJoiner) next; assert splitjoinJoiners.containsKey(joiner); int join_ways_remaining = splitjoinJoiners.get(joiner); if (join_ways_remaining > 1) { splitjoinJoiners.put(joiner, join_ways_remaining - 1); continue; } else { splitjoinJoiners.remove(joiner); } }
    private void findNextPhase() {        Iterator i = current_ops.iterator();        // iterate over nodes in current phase        while (i.hasNext()) {            SIROperator oper = (SIROperator)i.next();            Vector<NetStream> out = RegisterStreams.getNodeOutStreams(oper);            // check all nodes that are downstream from nodes in current phase            for (int a = 0; a < out.size(); a++) {                        SIROperator next =                     NodeEnumerator.getOperator(out.elementAt(a).getDest());                                /*                 * Here: if phases.containsKey, would be very surprised unless it is the                 * joiner of a feedbackloop.  In a feedbackloop need to schedule the loop before                 * the continuation. If a feedbackloop splitter has both a loop edge                 * and a contiuation edge then we have to modify the order in which we                 * iterate.                 */                // check if no phase assigned yet                if (!phases.containsKey(next)) {                     if (next instanceof SIRJoiner && next.getParent() instanceof SIRFeedbackLoop) {                        // first encounter with feedbackloop joiner (or would have had phases.containsKey(next))                        SIRSplitter loopSplitter = ((SIRFeedbackLoop)next.getParent()).getSplitter();                        // debugging: this should be first encounter with this feedbackloop joiner                        assert ! feedbackSplittersBody.contains(loopSplitter) && ! feedbackSplittersLoop.contains(loopSplitter);                        int split_ways =  RegisterStreams.getNodeOutStreams(loopSplitter).size();                        assert split_ways <= 2;                        // if non-degenerate feedback loop, then need some fancy work when encounter splitter                        if (split_ways == 2) {                            feedbackSplittersBody.add(loopSplitter);                        }                    }                                         if (next instanceof SIRSplitter && next.getParent() instanceof SIRFeedbackLoop                            && feedbackSplittersBody.contains(next)) {                        // if encounter splitter of non-degenerate feedbackloop, we "discover it"                        // and go from processing body to processing loop.                        feedbackSplittersBody.remove(next);                        feedbackSplittersLoop.add(next);                    }                    // if still processing feedbackloop, do not "discover" loop's continuation.                      if (a == 0 && oper instanceof SIRSplitter && feedbackSplittersLoop.contains(oper)) {                        continue;                    }                } else {                    assert next instanceof SIRJoiner && next.getParent() instanceof SIRFeedbackLoop                      && (feedbackSplittersLoop.contains(((SIRFeedbackLoop)next.getParent()).getSplitter())                              || RegisterStreams.getNodeInStreams(((SIRFeedbackLoop)next.getParent()).getSplitter()).size() < 2 )                        : "Node " + next + "is not the joiner of a FeedBackLoop being processed" ;                      // have processed body and loop, continuation is next                      SIRSplitter loopSplitter = ((SIRFeedbackLoop)next.getParent()).getSplitter();                      feedbackSplittersLoop.remove(loopSplitter);                      Vector<NetStream> nexts = RegisterStreams.getNodeOutStreams(loopSplitter);                      next = NodeEnumerator.getOperator(                              nexts.elementAt(0).getDest());                     }                phases.put(next, number_of_phases + 1);                next_ops.add(next);                // System.out.println("Operator: "+next+                // " assigned to phase: "+                // (number_of_phases+1));            }        }    }