@@ -97,7 +97,7 @@ public abstract class TypeFlow<T> {
9797 * the type flow graph.
9898 * <p/>
9999 * A type flow can also be marked as saturated when one of its inputs has reached the saturated
100- * state and has propagated the "saturated" marker downstream. Thus, since in such a situtation
100+ * state and has propagated the "saturated" marker downstream. Thus, since in such a situation
101101 * the input stops propagating type states, a flow's type state may be incomplete. It is up to
102102 * individual type flows to subscribe themselves directly to the type flows of their declared
103103 * types if they need further updates.
@@ -358,7 +358,7 @@ public boolean addUse(BigBang bb, TypeFlow<?> use) {
358358 private boolean addUse (BigBang bb , TypeFlow <?> use , boolean propagateTypeState , boolean registerInput ) {
359359 if (isSaturated () && propagateTypeState ) {
360360 /* Let the use know that this flow is already saturated. */
361- use . onInputSaturated (bb , this );
361+ notifyUseOfSaturation (bb , use );
362362 return false ;
363363 }
364364 if (doAddUse (bb , use , registerInput )) {
@@ -370,7 +370,7 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
370370 * use would have missed the saturated signal. Let the use know that this flow
371371 * became saturated.
372372 */
373- use . onInputSaturated (bb , this );
373+ notifyUseOfSaturation (bb , use );
374374 /* And unlink the use. */
375375 removeUse (use );
376376 return false ;
@@ -383,6 +383,10 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
383383 return false ;
384384 }
385385
386+ protected void notifyUseOfSaturation (BigBang bb , TypeFlow <?> use ) {
387+ use .onInputSaturated (bb , this );
388+ }
389+
386390 protected boolean doAddUse (BigBang bb , TypeFlow <?> use , boolean registerInput ) {
387391 if (use .isSaturated ()) {
388392 /* The use is already saturated so it will not be linked. */
@@ -420,14 +424,14 @@ public void addObserver(BigBang bb, TypeFlow<?> observer) {
420424 private boolean addObserver (BigBang bb , TypeFlow <?> observer , boolean triggerUpdate , boolean registerObservees ) {
421425 if (isSaturated () && triggerUpdate ) {
422426 /* Let the observer know that this flow is already saturated. */
423- observer . onObservedSaturated (bb , this );
427+ notifyObserverOfSaturation (bb , observer );
424428 return false ;
425429 }
426430 if (doAddObserver (bb , observer , registerObservees )) {
427431 if (triggerUpdate ) {
428432 if (isSaturated ()) {
429433 /* This flow is already saturated, notify the observer. */
430- observer . onObservedSaturated (bb , this );
434+ notifyObserverOfSaturation (bb , observer );
431435 removeObserver (observer );
432436 return false ;
433437 } else if (!this .state .isEmpty ()) {
@@ -449,6 +453,10 @@ public void run(DebugContext ignore) {
449453 return false ;
450454 }
451455
456+ protected void notifyObserverOfSaturation (BigBang bb , TypeFlow <?> observer ) {
457+ observer .onObservedSaturated (bb , this );
458+ }
459+
452460 private boolean doAddObserver (BigBang bb , TypeFlow <?> observer , boolean registerObservees ) {
453461 /*
454462 * An observer is linked even if it is already saturated itself, hence no
@@ -607,16 +615,24 @@ private void notifySaturated(BigBang bb) {
607615 /** This flow will swap itself out at all uses and observers. */
608616 protected void swapOut (BigBang bb , TypeFlow <?> newFlow ) {
609617 for (TypeFlow <?> use : getUses ()) {
610- removeUse (use );
611- newFlow .addUse (bb , use );
618+ swapAtUse (bb , newFlow , use );
612619 }
613620 for (TypeFlow <?> observer : getObservers ()) {
614- removeObserver (observer );
615- /* Notify the observer that its observed flow has changed. */
616- observer .replacedObservedWith (bb , newFlow );
621+ swapAtObserver (bb , newFlow , observer );
617622 }
618623 }
619624
625+ protected void swapAtUse (BigBang bb , TypeFlow <?> newFlow , TypeFlow <?> use ) {
626+ removeUse (use );
627+ newFlow .addUse (bb , use );
628+ }
629+
630+ protected void swapAtObserver (BigBang bb , TypeFlow <?> newFlow , TypeFlow <?> observer ) {
631+ removeObserver (observer );
632+ /* Notify the observer that its observed flow has changed. */
633+ observer .replacedObservedWith (bb , newFlow );
634+ }
635+
620636 /**
621637 * Notified by an input that it is saturated and it will stop sending updates.
622638 */
0 commit comments