Repeatedly evaluates the specified conditions until they are satisfied or the specified timeout (in seconds) has elapsed.

@param conditions the conditions to evaluate

@throws InterruptedException if evaluation is interrupted
490683
@ConditionBlock
  public void within(double seconds, Closure<?> conditions) throws InterruptedException  {
    long timeoutMillis = toMillis(seconds);
    long start = System.currentTimeMillis();
    long lastAttempt = 0;
    Thread.sleep(toMillis(initialDelay));

    long currDelay = toMillis(delay);
    int attempts = 0;

    while(true) {
      try {
        attempts++;
        lastAttempt = System.currentTimeMillis();
        GroovyRuntimeUtil.invokeClosure(conditions);
        return;
      } catch (Throwable e) {
        long elapsedTime = lastAttempt - start;
        if (elapsedTime >= timeoutMillis) {
          String msg = String.format("Condition not satisfied after %1.2f seconds and %d attempts", elapsedTime / 1000d, attempts);
          throw new SpockTimeoutError(seconds, msg, e);
        }
        final long timeout = Math.min(currDelay, start + timeoutMillis - System.currentTimeMillis());
        if (timeout > 0) {
          Thread.sleep(timeout);
        }
        currDelay *= factor;
      }
    }
  }
1279933
public boolean waitForCompletion(long duration, TimeUnit timeUnit) throws InterruptedException {
    synchronized (lock) {
      if (!isCompleted()) {
        lock.wait(timeUnit.toMillis(duration));
      }
      return isCompleted();
    }
  }
1035380
public void processTimeout(TimeoutEvent arg0) {
    synchronized (listeners) {
      Iterator<SipListener> iter = listeners.iterator();
      while (iter.hasNext() == true) {
        SipListener listener = (SipListener) iter.next();
        listener.processTimeout(arg0);
      }
    }
  }
399099
public void await(K k, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        if (!acquireLock(k).await(timeout, unit)) {
            throw new TimeoutException("Wait time for retrieving value for key " + k + " exceeded " + timeout + " " + unit);
        }
    }
66131
protected void checkPauseAndWait() {
		pauseLock.lock();
		try {
			while (paused && ! stopped) {
				pausedCondition.await();
			}
		} catch (InterruptedException e) {
		} finally {
			pauseLock.unlock();
		}
	}
620148
@Override
    public IPromise<T> onTimeout(Consumer timeoutHandler) {
        return then( (r,e) -> {
            if ( e == Timeout.INSTANCE ) {
                timeoutHandler.accept(e);
            }
        });
    }
830724
protected void waitForCommand(ITimerCallback callback, long timeout) throws WidgetTimeoutException {
		WaitForConditionTimer t = new WaitForConditionTimer(getByLocator(), callback);
		t.waitUntil(timeout);
	}
891174
@Override
    public synchronized Response get(long timeout, TimeUnit unit)
            throws InterruptedException, ExecutionException, TimeoutException {
        long now = System.currentTimeMillis();
        long mills = unit.toMillis(timeout);
        long toWait = mills;
        if (this.completed) {
            return this.getResult();
        } else if (toWait <= 0) {
            throw new TimeoutException("Timeout is smaller than 0.");
        } else {
            for (;;) {
                wait(toWait);
                if (this.completed) {
                    return this.getResult();
                }
                long gap = System.currentTimeMillis() - now;
                toWait = toWait - gap;
                if (toWait <= 0) {
                    throw new TimeoutException();
                }
            }
        }
    }
544721
Long waitForStart() throws InterruptedException, WorkRejectedException {
        long timeout = startTimeout == WorkManager.UNKNOWN ? WorkManager.INDEFINITE : startTimeout < fudgeFactor ? fudgeFactor : startTimeout;
        Object o = startupDurationQueue.poll(timeout, TimeUnit.MILLISECONDS);
        if (o instanceof WorkRejectedException)
            throw (WorkRejectedException) o;
        else
            return (Long) o;
    }
1201034
public static void wait(Object lock, long timeout) {
	try {
	    synchronized (lock) {
		lock.wait(timeout);
	    }
	}
	catch (InterruptedException e) {}
    }
945191
public void waitAndAssertForExpectedCondition(ExpectedCondition<?> condition, int timeout) {
        if (!waitForExpectedCondition(condition, timeout)) {
            fail(String.format("Element does not meet condition %1$s", condition.toString()));
        }
    }
45826
protected final void validateAssertionConditions(final Conditions conditions, final SAML2MessageContext context) {

        if (conditions == null) {
            return;
        }

        if (conditions.getNotBefore() != null && conditions.getNotBefore().minusSeconds(acceptedSkew).isAfterNow()) {
            throw new SAMLAssertionConditionException("Assertion condition notBefore is not valid");
        }

        if (conditions.getNotOnOrAfter() != null && conditions.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) {
            throw new SAMLAssertionConditionException("Assertion condition notOnOrAfter is not valid");
        }

        final String entityId = context.getSAMLSelfEntityContext().getEntityId();
        validateAudienceRestrictions(conditions.getAudienceRestrictions(), entityId);
    }
189698
public void addCondition(final Condition condition) {
        if (conditions_ == null) {
            conditions_ = new ArrayList<>();
        }
        conditions_.add(condition);
    }
1164076
public void waitUntilComplete(long timeout) {
        long base=System.currentTimeMillis();
        long now=0;
        lock.lock();
        try {
            while(processing || count.get() > 0) {
                long delay=timeout-now;
                if(delay <= 0)
                    break;
                try {
                    processing_done.await(delay, TimeUnit.MILLISECONDS);
                    now=System.currentTimeMillis()-base;
                }
                catch(InterruptedException e) {
                }
            }
        }
        finally {
            lock.unlock();
        }
    }
691735
public boolean waitForCondition(Condition condition, int timeout){
		final long endTime = SystemClock.uptimeMillis() + timeout;

		while (true) {
			final boolean timedOut = SystemClock.uptimeMillis() > endTime;
			if (timedOut){
				return false;
			}

			sleeper.sleep();

			if (condition.isSatisfied()){
				return true;
			}
		}
	}
947805
public void setTimeout(Duration timeout) {

        LettuceAssert.notNull(timeout, "Timeout duration must not be null");
        LettuceAssert.isTrue(!timeout.isNegative(), "Timeout duration must be greater or equal to zero");

        this.timeout = timeout;

        if (channelWriter instanceof CommandExpiryWriter) {
            ((CommandExpiryWriter) channelWriter).setTimeout(timeout);
        }
    }
1258149
public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
      cancelTimeoutTask();
      ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
      setTimeoutFuture(timeoutFuture);
   }