private Optional<MockTask> poll(Predicate<MockTask> predicate) {
        synchronized (this) {
            Optional<MockTask> result = Optional.ofNullable(tasks.peek()).filter(predicate);
            // Remove element from the queue if `predicate` returned `true`
            result.ifPresent(t -> tasks.poll());
            return result;
        }
    }
Check for any tasks that need to execute. Since this is a mock scheduler this check only occurs
when this method is called and the execution happens synchronously in the calling thread.
If you are using the scheduler associated with a MockTime instance this call be triggered automatically.
server-common/src/test/java/org/apache/kafka/server/util/MockScheduler.java