/** * Traverse this instance and all its predecessors unless they are marked as executed. * * @param accumulator state that is maintained over the traversal * @param aggregator visits the traversed instances * @param isMark whether traversed instances should be marked * @param <T> * @return the {@code accumulator} in its final state */ public <T> T traverse(T accumulator, Aggregator<T> aggregator, boolean isMark) { if (!this.isExecuted) { for (Iterator<LazyExecutionLineageNode> i = this.predecessors.iterator(); i.hasNext(); ) { LazyExecutionLineageNode predecessor = i.next(); accumulator = predecessor.traverse(accumulator, aggregator, isMark); if (predecessor.isExecuted) { i.remove(); } } accumulator = this.accept(accumulator, aggregator); if (isMark) this.markAsExecuted(); } return accumulator; }
@Override protected void markAsExecuted() { super.markAsExecuted(); assert !this.channelInstance.wasProduced(); this.channelInstance.markProduced(); this.channelInstance.noteDiscardedReference(false); }