code: public void await(long delay, TimeUnit timeUnit, int expectedResumes) throws TimeoutException {
      try {
        if (failure == null) {
          synchronized (this) {
            int remaining = remainingResumes.addAndGet(expectedResumes);
            if (remaining > 0)
              circuit.open();
          }
  
          if (delay == 0)
            circuit.await();
          else if (!circuit.await(delay, timeUnit)) {
            final int actualResumes = expectedResumes - remainingResumes.get();
            throw new TimeoutException(String.format(TIMEOUT_MESSAGE, expectedResumes, actualResumes));
          }
        }
      } catch (InterruptedException e) {
      } finally {
        remainingResumes.set(0);
        circuit.open();
        if (failure != null) {
          Throwable f = failure;
          failure = null;
          sneakyThrow(f);
        }
      }
    }
docs: Waits until the {@code delay} has elapsed, {@link #resume()} is called {@code expectedResumes} times, or the test
  is failed.
  
  @param delay Delay to wait for
  @param timeUnit TimeUnit to delay for
  @param expectedResumes Number of times {@link #resume()} is expected to be called before the awaiting thread is
  resumed
  @throws TimeoutException if the operation times out while waiting
  @throws AssertionError if any assertion fails while waiting