@@ -97,7 +97,7 @@ public abstract class TypeFlow<T> {
97
97
* the type flow graph.
98
98
* <p/>
99
99
* 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
101
101
* the input stops propagating type states, a flow's type state may be incomplete. It is up to
102
102
* individual type flows to subscribe themselves directly to the type flows of their declared
103
103
* types if they need further updates.
@@ -354,7 +354,7 @@ public boolean addUse(BigBang bb, TypeFlow<?> use) {
354
354
private boolean addUse (BigBang bb , TypeFlow <?> use , boolean propagateTypeState , boolean registerInput ) {
355
355
if (isSaturated () && propagateTypeState ) {
356
356
/* Let the use know that this flow is already saturated. */
357
- use . onInputSaturated (bb , this );
357
+ notifyUseOfSaturation (bb , use );
358
358
return false ;
359
359
}
360
360
if (doAddUse (bb , use , registerInput )) {
@@ -366,7 +366,7 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
366
366
* use would have missed the saturated signal. Let the use know that this flow
367
367
* became saturated.
368
368
*/
369
- use . onInputSaturated (bb , this );
369
+ notifyUseOfSaturation (bb , use );
370
370
/* And unlink the use. */
371
371
removeUse (use );
372
372
return false ;
@@ -379,6 +379,10 @@ private boolean addUse(BigBang bb, TypeFlow<?> use, boolean propagateTypeState,
379
379
return false ;
380
380
}
381
381
382
+ protected void notifyUseOfSaturation (BigBang bb , TypeFlow <?> use ) {
383
+ use .onInputSaturated (bb , this );
384
+ }
385
+
382
386
protected boolean doAddUse (BigBang bb , TypeFlow <?> use , boolean registerInput ) {
383
387
if (use .isSaturated ()) {
384
388
/* The use is already saturated so it will not be linked. */
@@ -416,14 +420,14 @@ public void addObserver(BigBang bb, TypeFlow<?> observer) {
416
420
private boolean addObserver (BigBang bb , TypeFlow <?> observer , boolean triggerUpdate , boolean registerObservees ) {
417
421
if (isSaturated () && triggerUpdate ) {
418
422
/* Let the observer know that this flow is already saturated. */
419
- observer . onObservedSaturated (bb , this );
423
+ notifyObserverOfSaturation (bb , observer );
420
424
return false ;
421
425
}
422
426
if (doAddObserver (bb , observer , registerObservees )) {
423
427
if (triggerUpdate ) {
424
428
if (isSaturated ()) {
425
429
/* This flow is already saturated, notify the observer. */
426
- observer . onObservedSaturated (bb , this );
430
+ notifyObserverOfSaturation (bb , observer );
427
431
removeObserver (observer );
428
432
return false ;
429
433
} else if (!this .state .isEmpty ()) {
@@ -445,6 +449,10 @@ public void run(DebugContext ignore) {
445
449
return false ;
446
450
}
447
451
452
+ protected void notifyObserverOfSaturation (BigBang bb , TypeFlow <?> observer ) {
453
+ observer .onObservedSaturated (bb , this );
454
+ }
455
+
448
456
private boolean doAddObserver (BigBang bb , TypeFlow <?> observer , boolean registerObservees ) {
449
457
/*
450
458
* An observer is linked even if it is already saturated itself, hence no
@@ -603,16 +611,24 @@ private void notifySaturated(BigBang bb) {
603
611
/** This flow will swap itself out at all uses and observers. */
604
612
protected void swapOut (BigBang bb , TypeFlow <?> newFlow ) {
605
613
for (TypeFlow <?> use : getUses ()) {
606
- removeUse (use );
607
- newFlow .addUse (bb , use );
614
+ swapAtUse (bb , newFlow , use );
608
615
}
609
616
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 );
613
618
}
614
619
}
615
620
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
+
616
632
/**
617
633
* Notified by an input that it is saturated and it will stop sending updates.
618
634
*/
0 commit comments