Exemple #1
0
  /** Move data down this list. */
  public void move() throws Exception {
    if (closed()) return;

    // Stop each valve that doesn't have a later working on its bins
    for (Valve valve : list) valve.stop(); // Throws an exception if one stopped it

    // Move data down the list, end to start
    Bin.move(last().out(), out); // Take from the last in the list
    for (Pair pair : Pair.pairs(list)) // Move data down the list, bottom to top
    Bin.move(((Valve) pair.a).out(), ((Valve) pair.b).in());
    Bin.move(in, first().in()); // Give to the first in the list

    // Start each valve that has data and space
    for (Valve valve : list) valve.start();
  }
Exemple #2
0
 /** true if this ValveList is empty of data. */
 public boolean isEmpty() throws Exception {
   if (in != null && in.hasData()) return false; // Not empty
   for (Valve valve : list) if (!valve.isEmpty()) return false;
   if (out != null && out.hasData()) return false;
   return true;
 }
Exemple #3
0
 /** Make a new list of Valve objects that will take in and or put out data. */
 public Flow(Update update, boolean in, boolean out) {
   this.update = update;
   list = new LinkedList<Valve>();
   if (in) this.in = Bin.medium(); // Make the requested bins
   if (out) this.out = Bin.medium();
 }