private boolean schedule ( Task task ) { int index = bufferIndex ( ) ; int buffered = bufferLengths . incrementAndGet ( index ) ; if ( task . isWrite ( ) ) { buffers [ index ] . add ( task ) ; drainStatus . set ( REQUIRED ) ; return false ; } // A buffer may discard a read task if its length exceeds a tolerance level if ( buffered <= MAXIMUM_BUFFER_SIZE ) { buffers [ index ] . add ( task ) ; return ( buffered <= BUFFER_THRESHOLD ) ; } else { // not optimized for fail-safe scenario bufferLengths . decrementAndGet ( index ) ; return false ; } }
Schedules the task to be applied to the page replacement policy .