void awaitNotEmpty(Timer timer) {
        lock.lock();
        try {
            while (completedFetches.isEmpty() && !wokenUp.compareAndSet(true, false)) {
                // Update the timer before we head into the loop in case it took a while to get the lock.
                timer.update();

                if (timer.isExpired()) {
                    if (Thread.interrupted())
                        throw new InterruptException("Thread interrupted.");
                    break;
                }

                if (!notEmptyCondition.await(timer.remainingMs(), TimeUnit.MILLISECONDS)) {
                    break;
                }
            }
        } catch (InterruptedException e) {
            throw new InterruptException("Timeout waiting for results from fetching records", e);
        } finally {
            lock.unlock();
            timer.update();
        }
    }
Allows the caller to await presence of data in the buffer. The method will block, returning only
under one of the following conditions:

<ol>
    <li>The buffer was already non-empty on entry</li>
    <li>The buffer was populated during the wait</li>
    <li>The remaining time on the {@link Timer timer} elapsed</li>
    <li>The thread was interrupted</li>
</ol>

@param timer Timer that provides time to wait
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareFetchBuffer.java