remove obsolete ships
[fleet.git] / misc / obsolete-ships / Mux.java
diff --git a/misc/obsolete-ships/Mux.java b/misc/obsolete-ships/Mux.java
new file mode 100644 (file)
index 0000000..86a2822
--- /dev/null
@@ -0,0 +1,28 @@
+package edu.berkeley.fleet.interpreter.ships;
+import edu.berkeley.fleet.interpreter.*;
+import edu.berkeley.fleet.*;
+
+import java.util.*;
+import java.io.*;
+
+public class Mux extends InterpreterShip {
+
+    DataInbox   ap      = new DataInbox(this,  "a");
+    DataInbox   bp      = new DataInbox(this,  "b");
+    DataInbox   choicep = new DataInbox(this, "select");
+    DataOutbox  out     = new DataOutbox(this, "out");
+
+    public Mux(Interpreter fleet, String name) { super(fleet, name); }
+
+    public String getBalsaName() { return "mux"; }
+
+    public void service() {
+        if (ap.dataReadyForShip() && bp.dataReadyForShip() && choicep.dataReadyForShip()) {
+            int a      = ap.removeDataForShip();
+            int b      = bp.removeDataForShip();
+            int choice = choicep.removeDataForShip();
+            out.addDataFromShip(choice==0 ? a : b);
+        }
+    }
+
+}