public synchronized boolean waitForState(int state) {
      switch (state) {
        case Processor.Configured:
          p.configure();
          break;
        case Controller.Realized:
          p.realize();
          break;
        case Controller.Prefetched:
          p.prefetch();
          break;
        case Controller.Started:
          p.start();
          break;
      }

      while (p.getState() < state && !error) {
        try {
          wait(1000);
        } catch (Exception e) {
        }
      }
      // p.removeControllerListener(this);
      return !(error);
    }
示例#2
0
  private synchronized boolean waitForState(Processor p, int state) {
    p.addControllerListener(new StateListener());
    failed = false;

    // Call the required method on the processor
    if (state == Processor.Configured) {
      p.configure();
    } else if (state == Processor.Realized) {
      p.realize();
    }

    // Wait until we get an event that confirms the
    // success of the method, or a failure event.
    // See StateListener inner class
    while (p.getState() < state && !failed) {
      synchronized (getStateLock()) {
        try {
          getStateLock().wait();
        } catch (InterruptedException ie) {
          return false;
        }
      }
    }

    if (failed) return false;
    else return true;
  }