code: private Future rerunUpdateAfterQueryFinishes(final Future queryFutureInProgress) {
          if (queryFutureInProgress == null) {
              throw new NullPointerException();
          }
          return getDatabase().getManager().runAsync(new Runnable() {
              @Override
              public void run() {
  
                  if (runningState.get() == false) {
                      Log.v(Log.TAG_QUERY, "%s: rerunUpdateAfterQueryFinishes.run() fired, but running state == false.  Ignoring.", this);
                      return;
                  }
  
                  while (true) {
                      try {
                          queryFutureInProgress.get();
                      } catch (InterruptedException e) {
                          continue;
                      } catch (CancellationException e) {
                          // can safely ignore these
                      } catch (ExecutionException e) {
                          Log.e(Log.TAG_QUERY, "Got exception waiting for queryFutureInProgress to finish", e);
                      }
                      break;
                  }
  
                  if (runningState.get() == false) {
                      Log.v(Log.TAG_QUERY, "%s: queryFutureInProgress.get() done, but running state == false.", this);
                      return;
                  }
  
                  update();
              }
          });
      }
docs: kick off async task that will wait until the query finishes, and after it
  does, it will run upate() again in case the current query in flight misses
  some of the recently added items.