@@ -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.
@@ -354,7 +354,7 @@ public boolean addUse(BigBang bb, TypeFlow<?> use) {
354354 private boolean addUse (BigBang bb , TypeFlow <?> use , boolean propagateTypeState , boolean registerInput ) {
355355 if (isSaturated () && propagateTypeState ) {
356356 /* Let the use know that this flow is already saturated. */
357- use . onInputSaturated (bb , this );
357+ notifyUseOfSaturation (bb , use );
358358 return false ;
359359 }
360360 if (doAddUse (bb , use , registerInput )) {
@@ -366,7 +366,7 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
366366 * use would have missed the saturated signal. Let the use know that this flow
367367 * became saturated.
368368 */
369- use . onInputSaturated (bb , this );
369+ notifyUseOfSaturation (bb , use );
370370 /* And unlink the use. */
371371 removeUse (use );
372372 return false ;
@@ -379,6 +379,10 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
379379 return false ;
380380 }
381381
382+ protected void notifyUseOfSaturation (BigBang bb , TypeFlow <?> use ) {
383+ use .onInputSaturated (bb , this );
384+ }
385+
382386 protected boolean doAddUse (BigBang bb , TypeFlow <?> use , boolean registerInput ) {
383387 if (use .isSaturated ()) {
384388 /* The use is already saturated so it will not be linked. */
@@ -416,14 +420,14 @@ public void addObserver(BigBang bb, TypeFlow<?> observer) {
416420 private boolean addObserver (BigBang bb , TypeFlow <?> observer , boolean triggerUpdate , boolean registerObservees ) {
417421 if (isSaturated () && triggerUpdate ) {
418422 /* Let the observer know that this flow is already saturated. */
419- observer . onObservedSaturated (bb , this );
423+ notifyObserverOfSaturation (bb , observer );
420424 return false ;
421425 }
422426 if (doAddObserver (bb , observer , registerObservees )) {
423427 if (triggerUpdate ) {
424428 if (isSaturated ()) {
425429 /* This flow is already saturated, notify the observer. */
426- observer . onObservedSaturated (bb , this );
430+ notifyObserverOfSaturation (bb , observer );
427431 removeObserver (observer );
428432 return false ;
429433 } else if (!this .state .isEmpty ()) {
@@ -445,6 +449,10 @@ public void run(DebugContext ignore) {
445449 return false ;
446450 }
447451
452+ protected void notifyObserverOfSaturation (BigBang bb , TypeFlow <?> observer ) {
453+ observer .onObservedSaturated (bb , this );
454+ }
455+
448456 private boolean doAddObserver (BigBang bb , TypeFlow <?> observer , boolean registerObservees ) {
449457 /*
450458 * An observer is linked even if it is already saturated itself, hence no
@@ -603,16 +611,24 @@ private void notifySaturated(BigBang bb) {
603611 /** This flow will swap itself out at all uses and observers. */
604612 protected void swapOut (BigBang bb , TypeFlow <?> newFlow ) {
605613 for (TypeFlow <?> use : getUses ()) {
606- removeUse (use );
607- newFlow .addUse (bb , use );
614+ swapAtUse (bb , newFlow , use );
608615 }
609616 for (TypeFlow <?> observer : getObservers ()) {
610- removeObserver (observer );
611- /* Notify the observer that its observed flow has changed. */
612- observer .replacedObservedWith (bb , newFlow );
617+ swapAtObserver (bb , newFlow , observer );
613618 }
614619 }
615620
621+ protected void swapAtUse (BigBang bb , TypeFlow <?> newFlow , TypeFlow <?> use ) {
622+ removeUse (use );
623+ newFlow .addUse (bb , use );
624+ }
625+
626+ protected void swapAtObserver (BigBang bb , TypeFlow <?> newFlow , TypeFlow <?> observer ) {
627+ removeObserver (observer );
628+ /* Notify the observer that its observed flow has changed. */
629+ observer .replacedObservedWith (bb , newFlow );
630+ }
631+
616632 /**
617633 * Notified by an input that it is saturated and it will stop sending updates.
618634 */
0 commit comments