1 package edu.berkeley.fleet.api;
6 * Represents a <i>running</i> "slave" fleet with debugging
7 * facilities controlled by the "master" JVM.
9 * <p>Each Fleet which supports this API must include:
10 * <ul><li> The ability to dispatch instructions, words, and tokens
11 * from the master, "on the fly".
12 * <li> A "debug.in" dock such that any words delivered there
13 * are sent back to the master.
16 public abstract class FleetProcess {
18 private boolean terminated = false;
20 /** dispatch an instruction; may be buffered */
21 public abstract void sendInstruction(Instruction i);
23 /** dispatch a word to a given destination; may be buffered */
24 public abstract void sendWord(Destination d, BitVector word);
26 /** dispatch a word to a given destination; may be buffered */
27 public abstract void sendWord(Destination d, BitVector word, BitVector signal);
29 /** convenience method: sends the word to d's data destination */
30 public void sendWord(Dock d, BitVector word) { sendWord(d.getDataDestination(), word); }
32 /** dispatch a token to a given destination; may be buffered */
33 public abstract void sendToken(Destination d);
35 /** convenience method: sends a token to d's data destination */
36 public void sendToken(Dock d) { sendToken(d.getDataDestination()); }
38 /** convenience method: sends a token to d's instruction destination */
39 public void sendTorpedo(Dock d) { sendToken(d.getInstructionDestination()); }
41 /** flush all instructions, words, and tokens dispatched so far */
42 public abstract void flush();
44 /** the dock used to read back data from the slave */
45 public abstract Dock getDebugInputDock();
47 /** returns the next word delivered at the dock specified by <tt>getDebugInputDock()</tt> */
48 public abstract BitVector recvWord();
50 /** Terminate the process; subclasses may be assured that this will be called exactly once. */
51 protected abstract void _terminate();
53 public void masterClear() { throw new RuntimeException("not implemented"); }
55 /** Terminate the process. */
56 public final synchronized void terminate() {
57 if (terminated) return;
62 /** Returns true if the process is terminated */
63 public final boolean isTerminated() { return terminated; }
65 public synchronized void finalize() { terminate(); }
67 /** return the Fleet that this FleetProcess controls */
68 public abstract Fleet getFleet();