move InterpreterDestination serial number into the Interpreter class
[fleet.git] / src / edu / berkeley / fleet / interpreter / InterpreterDestination.java
index 49b56a6..df86579 100644 (file)
@@ -4,18 +4,10 @@ import java.util.*;
 
 abstract class InterpreterDestination extends Destination {
 
-    private static int max_dest = 0;
-
-    int addr;
-
-    private boolean isInstructionDestination;
-
-    public InterpreterDestination(InterpreterDock d, boolean isInstructionDestination) {
+    public InterpreterDestination(InterpreterDock d) {
         super(d);
-        this.isInstructionDestination = isInstructionDestination;
-        synchronized(InterpreterDestination.class) {
-            this.addr = max_dest;
-            max_dest++;
+        synchronized(d.getInterpreter()) {
+            this.serialNumber = d.getInterpreter().maxAllocatedDestinationSerialNumber++;
         }
     }
 
@@ -23,4 +15,14 @@ abstract class InterpreterDestination extends Destination {
     public abstract void addDataFromFabric(Packet packet);
     public abstract String toString();
 
+    /**
+     *  The Fleet instruction encoding mechanism assumes that each
+     *  source->dest path can be turned into a bitstring, and that the
+     *  bitstring gives sufficient information to route the packet.
+     *  Therefore, the interpreter assigns a "serial number" to every
+     *  InterpreterDestination in a fleet and uses the serial number
+     *  of the destination as the path.
+     */
+    private int serialNumber;
+    int getSerialNumber() { return serialNumber; }
 }