public List < MemorySegment > close ( ) throws IOException { // send off set last segment writeSegment ( getCurrentSegment ( ) , getCurrentPositionInSegment ( ) , true ) ; clear ( ) ; // close the writer and gather all segments final LinkedBlockingQueue < MemorySegment > queue = this . writer . getReturnQueue ( ) ; this . writer . close ( ) ; // re-collect all memory segments ArrayList < MemorySegment > list = new ArrayList < MemorySegment > ( this . numSegments ) ; for ( int i = 0 ; i < this . numSegments ; i ++ ) { final MemorySegment m = queue . poll ( ) ; if ( m == null ) { // we get null if the queue is empty. that should not be the case if the reader was properly closed. throw new RuntimeException ( "ChannelWriterOutputView: MemorySegments have been taken from return queue by different actor." ) ; } list . add ( m ) ; } return list ; }
Closes this OutputView closing the underlying writer and returning all memory segments .