public int poll ( final long now , final TimerHandler handler , final int maxTimersToExpire ) { int timersExpired = 0 ; if ( timerCount > 0 ) { final long [ ] array = wheel [ currentTick & wheelMask ] ; for ( int i = 0 , length = array . length ; i < length && maxTimersToExpire > timersExpired ; i ++ ) { final long deadline = array [ pollIndex ] ; if ( deadline <= now ) { array [ pollIndex ] = NULL_TIMER ; timerCount -- ; timersExpired ++ ; if ( ! handler . onTimerExpiry ( timeUnit , now , timerIdForSlot ( currentTick & wheelMask , pollIndex ) ) ) { array [ pollIndex ] = deadline ; timerCount ++ ; return timersExpired ; } } pollIndex = ( pollIndex + 1 ) >= length ? 0 : ( pollIndex + 1 ) ; } if ( maxTimersToExpire > timersExpired && currentTickTime ( ) <= now ) { currentTick ++ ; pollIndex = 0 ; } else if ( pollIndex >= array . length ) { pollIndex = 0 ; } } else if ( currentTickTime ( ) <= now ) { currentTick ++ ; pollIndex = 0 ; } return timersExpired ; }
Poll for timers expired by the deadline passing .