public int poll(final long now)
    {
        int expiredTimers = 0;
        final Timer[] timers = this.timers;
        final TimerHandler timerHandler = this.timerHandler;

        while (size > 0 && expiredTimers < POLL_LIMIT)
        {
            final Timer timer = timers[0];
            if (timer.deadline > now)
            {
                break;
            }

            if (!timerHandler.onTimerEvent(timer.correlationId))
            {
                break;
            }

            expiredTimers++;
            final int lastIndex = --size;
            final Timer lastTimer = timers[lastIndex];
            timers[lastIndex] = null;

            if (0 != lastIndex)
            {
                shiftDown(timers, lastIndex, 0, lastTimer);
            }

            timerByCorrelationId.remove(timer.correlationId);
            addToFreeList(timer);
        }

        return expiredTimers;
    }
@Test
    void pollIsANoOpWhenNoTimersWhereScheduled()
    {
        final TimerHandler timerHandler = mock(TimerHandler.class);
        final PriorityHeapTimerService timerService = new PriorityHeapTimerService(timerHandler);

        assertEquals(0, timerService.poll(Long.MIN_VALUE));

        verifyNoInteractions(timerHandler);
    }