void awaitNotEmpty(Timer timer) {
        try {
            lock.lock();

            while (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 the thread was interrupted before we start waiting, it still counts as
                    // interrupted from the point of view of the KafkaConsumer.poll(Duration) contract.
                    // We only need to check this when we are not going to wait because waiting
                    // already checks whether the thread is interrupted.
                    if (Thread.interrupted())
                        throw new InterruptException("Interrupted waiting for results from fetching records");

                    break;
                }

                if (!notEmptyCondition.await(timer.remainingMs(), TimeUnit.MILLISECONDS)) {
                    break;
                }
            }
        } catch (InterruptedException e) {
            throw new InterruptException("Interrupted 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/FetchBuffer.java