Wait for activity to become active (by component name)

@param name
@param retryTime
18407
public boolean waitForActivity(ComponentName name, int retryTime) {
        final int retryPeriod = 250;
        int retryNum = retryTime / retryPeriod;
        for (int i = 0; i < retryNum; i++) {
            if (this.getCurrentActivity().getComponentName().equals(name)) {
                break;
            }
            if (i == retryNum - 1) {
                return false;
            }
            this.sleep(retryPeriod);
        }
        return true;
    }
939864
@Override
	public boolean onActivityTimeout() throws Exception
    {
    	// Called by watchdog if queue is inactive
    	if (closed)
    		return true;
    	
    	if (getSize() == 0)
    		return false; // Queue is empty
    	
    	// Notify next consumer
    	notifyConsumer(null);

    	return false;
    }
433224
public static void failureCookie(HttpServletRequest request,
                                     HttpServletResponse response, String name) {
        failureCookie(request, response, name, null);
    }
646445
public static void waitWhileState(final DeviceProxy proxy, final DevState waitState, final long timeout)
	    throws DevFailed, TimeoutException {
	waitWhileState(proxy, waitState, timeout, 300);
    }
838914
private void connect(int attempt, CompletableFuture<SessionClient> future) {
    if (attempt > MAX_ATTEMPTS) {
      future.completeExceptionally(new PrimitiveException.Unavailable());
      return;
    }

    primaryElection.getTerm().whenCompleteAsync((term, error) -> {
      if (error == null) {
        if (term.primary() == null) {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        } else {
          this.term = term;
          protocol.registerEventListener(sessionId, this::handleEvent, threadContext);
          future.complete(this);
        }
      } else {
        Throwable cause = Throwables.getRootCause(error);
        if (cause instanceof PrimitiveException.Unavailable || cause instanceof TimeoutException) {
          threadContext.schedule(Duration.ofMillis(RETRY_DELAY), () -> connect(attempt + 1, future));
        } else {
          future.completeExceptionally(new PrimitiveException.Unavailable());
        }
      }
    }, threadContext);
  }
1023999
@Override
	public void waitForElementPresent(long time) throws WidgetException {
		try {
			waitForCommand(new ITimerCallback() {

				@Override
				public boolean execute() {
					try {
						return isElementPresent();
					} catch (WidgetException e) {
						return false;
					}
				}

				@Override
				public String toString() {
					return "Waiting for Element: " + locator + " to be present";
				}
			}, time);
		} catch (WidgetTimeoutException e) {
			throw new WidgetException("Error while waiting for element to be present", locator, e);
		}
	}
203200
public void active(String name) {
        SmartForest<NewWord> branch = sf.getBranch(name);
        if (branch != null && branch.getParam() != null) {
            branch.getParam().setActive(true);
        }
    }
262811
public static void step(final String name, final ThrowableRunnableVoid runnable) {
        step(name, () -> {
            runnable.run();
            return null;
        });
    }
1216331
synchronized void scheduleRetry(long retryInterval)
    {
        // Synchronized to insure a destroyed or cancelled (ivTaskHanler=null)
        // timer is not re-scheduled. If the timer is in the cancelled state
        // but not yet destroyed, then reset the expiration back to the last
        // expiration since it was never completed successfully. If the cancel
        // does rollback then schedule will be called again and re-create the
        // task handler. The only side effect of this is that the retry count
        // is reset; so the timer may experience more retries than configured. RTC107334

        if (!ivDestroyed)
        {
            if (ivTaskHandler != null)
            {
                ivTaskHandler.scheduleRetry(retryInterval);
            }
            else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "scheduleRetry: not scheduled, timer in cancelled state : " + ivTaskId);
                ivExpiration = ivLastExpiration;
            }
        }
    }
1275527
@Override
    public void retry(VolleyError error) throws VolleyError {
        mCurrentRetryCount++;
        mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier);
        if (!hasAttemptRemaining()) {
            throw error;
        }
    }
1065950
@SuppressWarnings("unchecked")
  protected <T extends RaftRequest> void retryRequest(Throwable cause, T request, BiFunction sender, int count, int selectionId, CompletableFuture future) {
    // If the connection has not changed, reset it and connect to the next server.
    if (this.selectionId == selectionId) {
      log.trace("Resetting connection. Reason: {}", cause.getMessage());
      this.currentNode = null;
    }

    // Attempt to send the request again.
    sendRequest(request, sender, count, future);
  }
1333330
private void scheduleRetry() {
        Context appContext = getApplicationContext();
        long nextRetry = System.currentTimeMillis() + RetryPolicy.incrementAndGetTime(appContext);
        scheduleWingsService(appContext, nextRetry);
    }
977431
private synchronized <R> OperationResult<R> executeDdlOperation(AbstractOperationImpl<R> operation, RetryPolicy retry)
             throws OperationException, ConnectionException {
         ConnectionException lastException = null;
         for (int i = 0; i < 2; i++) {
             operation.setPinnedHost(ddlHost);
             try {
                 OperationResult<R> result = connectionPool.executeWithFailover(operation, retry);
                 ddlHost = result.getHost();
                 return result;
             }
             catch (ConnectionException e) {
                lastException = e;
                if (e instanceof IsDeadConnectionException) {
                     ddlHost = null;
                }
             }
         }
         throw lastException;
    }
886839
public RetryBuilder delay(Delay delay, Scheduler scheduler) {
    this.delay = (delay == null) ? Retry.DEFAULT_DELAY : delay;
    this.scheduler = scheduler;
    return this;
  }
111528
private static Object waitForServiceFromTracker(ServiceTracker tracker, long timeout)
        throws OsgiServiceNotAvailableException {
        synchronized (tracker) {
            tracker.open();
            try {
                return tracker.waitForService(timeout);
            } catch (InterruptedException e) {
                throw new OsgiServiceNotAvailableException(e);
            } finally {
                tracker.close();
            }
        }
    }
1171783
public final void retry(final ConnectionState state, final RetryHandler retryHandler, final ConnectionFailHandler failHandler) throws RetryCancelled {
    if (state.retryCount == 0) {
      state.msBeforeRetry = this.startRetryTime;
    }

    state.retryCount++;
    state.uriIndex = state.retryCount % state.uris.length;

    if (this.shouldRetry(state)) {
      if (logger.isDebugEnabled()) {
        logger.debug("Retry {} to send command", state.retryCount);
      }

      if(state.msBeforeRetry > 0) {
        try {
          state.loop.schedule(new Runnable() {
            @Override
            public void run() {
              try {
                retryHandler.doRetry(state);
              } catch (IOException e) {
                failHandler.catchException(e);
              }
            }
          }, state.msBeforeRetry, TimeUnit.MILLISECONDS);
        } catch (IllegalStateException e) {
          failHandler.catchException(
            new IOException(new CancellationException("Etcd client was closed"))
          );
        }
      } else {
        try {
          retryHandler.doRetry(state);
        } catch (IOException e) {
          failHandler.catchException(e);
        }
      }
    } else {
      throw new RetryCancelled();
    }
  }
1076094
public static <T> T queueAndWait (
        RunQueue runq, final String name, final Callable<T> action)
        throws ServiceException
    {
        final ServletWaiter<T> waiter = new ServletWaiter<T>(name);
        runq.postRunnable(new Runnable() {
            public void run () {
                try {
                    waiter.postSuccess(action.call());
                } catch (final Exception e) {
                    waiter.postFailure(e);
                }
            }
        });
        return waiter.waitForResult();
    }