Exemplo n.º 1
0
  void _sleepUntil(double time_, String poststate_) {
    if (poststate_ == null) poststate_ = state;

    setWakeupTime(time_);
    // set the following two lines before calling
    // runtime.threadRequestsWaiting() to avoid racing
    // (see codes below)
    if (sleepOn == null) sleepOn = this;
    // for wait(Object, double), sleepOn is preset
    synchronized (sleepOn) {
      if (nextTask != null) _semanticsError("sleep()");
      if (aruntime.threadRequestsSleeping(this, time_)) {
        __sleepOn(sleepOn, State_SLEEPING, State_AWAKENING);
        // runtime.threadAwakeFromSleeping(this);
        if (aruntime.debug && aruntime.isDebugEnabledAt(aruntime.Debug_Q))
          aruntime.println(
              aruntime.Debug_Q, this, "awaked from finite sleep, " + _currentContext());
      }
      setWakeupTime(Double.NaN);
    }
    setState(poststate_);
  }