Question about AsynchronousByteChannel.read() (original) (raw)
Alan Bateman Alan.Bateman at oracle.com
Wed Jul 13 01:31:25 PDT 2011
- Previous message: Question about AsynchronousByteChannel.read()
- Next message: Question about AsynchronousByteChannel.read()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
cowwoc wrote:
Hi,
According to the Javadoc of read(ByteBuffer, A, CompletionHandler<Integer,? super A>): "This method may be invoked at any time. Some channel types may not allow more than one read to be outstanding at any given time. If a thread initiates a read operation before a previous read operation has completed then a ReadPendingException will be thrown." On the one hand you're indicating that that some channels support do multiple read requests. On the other hand you're saying if multiple requests are issued, ReadPendingException will be thrown. Did you mean to imply that ReadPendingException will only be thrown if the channel implementation does not support multiple reads but in other channel implementations it might work just fine? Yes, it depends on the channel type. With a channel to a stream oriented connection then it doesn't always make sense to have more than one outstanding I/O operations of a given type as they would complete in an undefined order (and with an operation such as write then it would easily "corrupt" the stream for example). However it does make sense for other channel types, for example AsynchronousFileChannel where there may be I/O operations to different parts of the file happening at the same thing. If you go back through the archives of this list then you should find some prior discussion on queuing of I/O operations that make be useful to you.
-Alan.
- Previous message: Question about AsynchronousByteChannel.read()
- Next message: Question about AsynchronousByteChannel.read()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]