public void requestTick ( long time , TimeUnit timeUnit ) { long timeframeMs = TimeUnit . MILLISECONDS . convert ( time , timeUnit ) ; long currentTime = System . currentTimeMillis ( ) ; boolean isWaiting = false ; // if we have Toe request queued - we' have to wait till it finishes. try { while ( isToeScheduled . get ( ) || isToeWaiting . get ( ) || getCurrentState ( ) == AccessState . TOE ) { if ( ! isWaiting ) { isWaiting = true ; waitingTicks . incrementAndGet ( ) ; } Thread . sleep ( 50 ) ; } currentState . set ( AccessState . TICK . ordinal ( ) ) ; waitingTicks . decrementAndGet ( ) ; tickRequests . incrementAndGet ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method requests to change state to Tick .