code: @Override
      public IPromise<T> awaitPromise(long timeout) {
          long endtime = 0;
          if ( timeout > 0 ) {
              endtime = System.currentTimeMillis() + timeout;
          }
          if ( Thread.currentThread() instanceof DispatcherThread ) {
              DispatcherThread dt = (DispatcherThread) Thread.currentThread();
              Scheduler scheduler = dt.getScheduler();
              int idleCount = 0;
              dt.__stack.add(this);
              while( ! isSettled() ) {
                  if ( ! dt.pollQs() ) {
                      idleCount++;
                      scheduler.pollDelay(idleCount);
                  } else {
                      idleCount = 0;
                  }
                  if ( endtime != 0 && System.currentTimeMillis() > endtime && ! isSettled() ) {
                      timedOut(Timeout.INSTANCE);
                      break;
                  }
              }
              dt.__stack.remove(dt.__stack.size()-1);
              return this;
          } else {
              // if outside of actor machinery, just block
              CountDownLatch latch = new CountDownLatch(1);
              then( (res, err) -> {
                  latch.countDown();
              });
              boolean timedOut = false;
              try {
                  timedOut = ! latch.await(timeout, TimeUnit.MILLISECONDS);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              if ( timedOut )
                  timedOut(Timeout.INSTANCE);
              return this;
          }
      }
docs: see IPromise (inheriting Callback) interface
  @param timeout