/** * Disposes this instance. */ protected void dispose() { // Drop references towards the #inputChannelInstances. for (ChannelInstance inputChannelInstance : this.inputChannelInstances) { if (inputChannelInstance != null) { inputChannelInstance.noteDiscardedReference(true); } } }
@Override protected void disposeUnreferenced() { for (ChannelInstance channelInstance : channelInstances.values()) { channelInstance.noteDiscardedReference(true); } this.channelInstances = null; }
/** * Mark that this instance should not be traversed any more. */ protected void markAsExecuted() { LoggerFactory.getLogger(this.getClass()).debug("Marking {} as executed.", this); this.isExecuted = true; // Free pinned down ChannelInstances. for (ChannelInstance channelInstance : this.pinnedDownChannelInstances) { channelInstance.noteDiscardedReference(true); } this.pinnedDownChannelInstances.clear(); }
/** * Dispose this instance, in particular discard references to its {@link ChannelInstance}s. */ void dispose() { // Release the inputChannelInstances. for (ChannelInstance channelInstance : this.inputChannelInstances.values()) { channelInstance.noteDiscardedReference(true); } this.inputChannelInstances.clear(); // Release the loopContext. if (this.loopContext != null) { this.loopContext.noteDiscardedReference(true); } }
/** * Registers the given {@link ChannelInstance} with this instance. * * @param channelInstance that should be registered */ public void register(ChannelInstance channelInstance) { channelInstance.noteObtainedReference(); final ChannelInstance oldInstance = this.channelInstances.put(channelInstance.getChannel(), channelInstance); if (oldInstance != null) oldInstance.noteDiscardedReference(true); }
@Override protected void markAsExecuted() { super.markAsExecuted(); assert !this.channelInstance.wasProduced(); this.channelInstance.markProduced(); this.channelInstance.noteDiscardedReference(false); }
/** * Execute one single {@link ExecutionStage} */ private void executeSingleStage(boolean isBreakpointsDisabled, StageActivator stageActivator) { // Check if #breakpoint permits the execution. if (!isBreakpointsDisabled && this.suspendIfBreakpointRequest(stageActivator)) { return; } // Otherwise, execute the stage. this.execute(stageActivator); // Try to activate the successor stages. this.tryToActivateSuccessors(stageActivator); // We can now dispose the stageActivator that collected the input ChannelInstances. stageActivator.dispose(); // Dispose obsolete ChannelInstances. final Iterator<Map.Entry<Channel, ChannelInstance>> iterator = this.channelInstances.entrySet().iterator(); while (iterator.hasNext()) { final Map.Entry<Channel, ChannelInstance> channelInstanceEntry = iterator.next(); final ChannelInstance channelInstance = channelInstanceEntry.getValue(); // If this is instance is the only one to still use this ChannelInstance, discard it. if (channelInstance.getNumReferences() == 1) { channelInstance.noteDiscardedReference(true); iterator.remove(); } } }
/** * Put new {@link ChannelInstance}s to the {@link #executionState} and release input {@link ChannelInstance}s. */ private void updateExecutionState() { for (final ChannelInstance channelInstance : this.allChannelInstances) { // Capture outbound ChannelInstances. if (channelInstance.getChannel().isBetweenStages() || channelInstance.getChannel().getConsumers().stream() .anyMatch(consumer -> consumer.getOperator().isLoopHead())) { this.executionState.register(channelInstance); } // Release the ChannelInstance. channelInstance.noteDiscardedReference(true); } this.allChannelInstances.clear(); } }
channelInstance.noteDiscardedReference(true); iterator.remove();
@Override public void register(ChannelInstance channelInstance) { final ExecutionStageLoop loop = getExecutionStageLoop(channelInstance.getChannel()); if (loop == null) { final ChannelInstance oldChannelInstance = this.channelInstances.put(channelInstance.getChannel(), channelInstance); channelInstance.noteObtainedReference(); if (oldChannelInstance != null) { oldChannelInstance.noteDiscardedReference(true); } } else { final ExecutionStageLoopContext loopContext = this.getOrCreateLoopContext(loop); loopContext.register(channelInstance); } }