+
package edu.berkeley.fleet.interpreter;
import edu.berkeley.fleet.api.*;
import edu.berkeley.fleet.two.*;
public abstract void service();
public final void _service() {
+
+ // service all the docks
for(InterpreterDock p : docks.values()) p.service();
+
+ // flushing logic (must come between dock servicing and subclass)
+ boolean someflushing = false;
+ boolean allflushing = true;
+ boolean someempty = false;
+ for(InterpreterDock d : docks.values()) {
+ if (!d.isInputDock()) continue;
+ if (d.flushing) someflushing = true;
+ else allflushing = false;
+ if (!d.flushing && !d.dataReadyForShip) someempty = true;
+ }
+ if (allflushing && someflushing) {
+ for(InterpreterDock d : docks.values())
+ if (d.isInputDock())
+ d.flushing = false;
+ return;
+ } else if (someflushing && !someempty) {
+ for(InterpreterDock d : docks.values())
+ if (d.isInputDock() && !d.flushing && d.dataReadyForShip)
+ d.dataReadyForShip = false;
+ }
+
+ // now pass control to the subclass
service();
}