public void readBlock ( MemorySegment segment ) throws IOException { // check the error state of this channel checkErroneous ( ) ; // write the current buffer and get the next one // the statements have to be in this order to avoid incrementing the counter // after the channel has been closed this . requestsNotReturned . incrementAndGet ( ) ; if ( this . closed || this . requestQueue . isClosed ( ) ) { // if we found ourselves closed after the counter increment, // decrement the counter again and do not forward the request this . requestsNotReturned . decrementAndGet ( ) ; throw new IOException ( "The reader has been closed." ) ; } this . requestQueue . add ( new SegmentReadRequest ( this , segment ) ) ; }
Issues a read request which will asynchronously fill the given segment with the next block in the underlying file channel . Once the read request is fulfilled the segment will be added to this reader s return queue .