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 token to a given destination; may be buffered */
27 public abstract void sendToken(Destination d);
29 /** flush all instructions, words, and tokens dispatched so far */
30 public abstract void flush();
32 /** the dock used to read back data from the slave */
33 public abstract Dock getDebugInputDock();
35 /** returns the next word delivered at the dock specified by <tt>getDebugInputDock()</tt> */
36 public abstract BitVector recvWord();
38 /** Terminate the process; subclasses may be assured that this will be called exactly once. */
39 protected abstract void _terminate();
41 /** Terminate the process. */
42 public final synchronized void terminate() {
43 if (terminated) return;
48 /** Returns true if the process is terminated */
49 public final boolean isTerminated() { return terminated; }
51 public synchronized void finalize() { terminate(); }
53 /** return the Fleet that this FleetProcess controls */
54 public abstract Fleet getFleet();