add FleetProcess.sendWord() that takes a signal
[fleet.git] / src / edu / berkeley / fleet / api / FleetProcess.java
index ef9297c..c232405 100644 (file)
@@ -7,8 +7,8 @@ import java.util.*;
  *  facilities controlled by the "master" JVM.
  *
  *  <p>Each Fleet which supports this API must include:
- *  <ul><li> The ability to dispatch instructions from the master, "on
- *           the fly".
+ *  <ul><li> The ability to dispatch instructions, words, and tokens
+ *           from the master, "on the fly".
  *      <li> A "debug.in" dock such that any words delivered there
  *           are sent back to the master.
  *  </ul>
@@ -17,24 +17,51 @@ public abstract class FleetProcess {
 
     private boolean terminated = false;
 
-    /** dispatch an instruction */
-    public abstract void dispatchInstruction(Instruction i);
+    /** dispatch an instruction; may be buffered */
+    public abstract void sendInstruction(Instruction i);
+
+    /** dispatch a word to a given destination; may be buffered */
+    public abstract void sendWord(Destination d, BitVector word);
+
+    /** dispatch a word to a given destination; may be buffered */
+    public abstract void sendWord(Destination d, BitVector word, BitVector signal);
+
+    /** convenience method: sends the word to d's data destination */
+    public void sendWord(Dock d, BitVector word) { sendWord(d.getDataDestination(), word); }
+
+    /** dispatch a token to a given destination; may be buffered */
+    public abstract void sendToken(Destination d);
+
+    /** convenience method: sends a token to d's data destination */
+    public void sendToken(Dock d) { sendToken(d.getDataDestination()); }
+
+    /** convenience method: sends a token to d's instruction destination */
+    public void sendTorpedo(Dock d) { sendToken(d.getInstructionDestination()); }
+
+    /** flush all instructions, words, and tokens dispatched so far */
+    public abstract void flush();
 
     /** the dock used to read back data from the slave */
     public abstract Dock getDebugInputDock();
 
     /** returns the next word delivered at the dock specified by <tt>getDebugInputDock()</tt> */
-    public abstract BitVector readWord();
+    public abstract BitVector recvWord();
 
     /** Terminate the process; subclasses may be assured that this will be called exactly once. */
     protected abstract void _terminate();
 
+    /** Terminate the process. */
     public final synchronized void terminate() {
         if (terminated) return;
         terminated = true;
         _terminate();
     }
 
+    /** Returns true if the process is terminated */
     public final boolean isTerminated() { return terminated; }
+
     public synchronized void finalize() { terminate(); }
+
+    /** return the Fleet that this FleetProcess controls */
+    public abstract Fleet getFleet();
 }