private AsyncResourceRequest < V > getNextUnexpiredResourceRequest ( Queue < AsyncResourceRequest < V > > requestQueue ) { AsyncResourceRequest < V > resourceRequest = requestQueue . poll ( ) ; while ( resourceRequest != null ) { if ( resourceRequest . getDeadlineNs ( ) < System . nanoTime ( ) ) { resourceRequest . handleTimeout ( ) ; resourceRequest = requestQueue . poll ( ) ; } else { break ; } } return resourceRequest ; }
Pops resource requests off the queue until queue is empty or an unexpired resource request is found . Invokes . handleTimeout on all expired resource requests popped off the queue .