class RevAwaiter {

    void await(long rev, Duration maxWaitTime) throws TimeoutException, InterruptedException {
        if (currentRev.get() >= rev) {
            return;
        }
        AwaitableRev awaitable = new AwaitableRev(rev);
        synchronized (pq) {
            pq.add(awaitable);
        }
        synchronized (awaitable) {
            // account for possible spurious wake up
            @Var long now = System.nanoTime();
            long deadline = now + maxWaitTime.toNanos();
            while (currentRev.get() < rev && now < deadline) {
                // http://errorprone.info/bugpattern/WaitNotInLoop
                awaitable.wait((deadline - now) / 1000000);
                now = System.nanoTime();
            }
            if (now >= deadline) {
                throw new TimeoutException();
            }
            // else it's a real awaitable.notify(), not spurious nor timeout, and we return to caller.
        }
    }

      RevAwaiter(String nodeName);

}