AsynchronousFileChannel.transferTo?

Benedict Elliott Smith lists at laerad.com
Mon Dec 5 14:58:16 PST 2011


Thanks - at least I can stop looking for the moment. I guess since it's not
on anyone's radar, it's pretty much off the cards for Java 8 (and possibly
beyond)?

I suppose that other than synchronous/asynchronous target/source, you have
to consider the semantics for non-standard Channel implementations as well,
as a poorly designed and/or synchronous channel could occupy a lot of the
asynchronous channel's executor service's time.

I think intuitively it should be asynchronous channels on both sides of the
method (seems wrong to mix async/sync io), and this would also (help to)
solve that problem, but then you might need a different method for file and
socket, or could you perhaps create an AsynchronousByteChannel from an
AsynchronousFileChannel, which contains an offset as well. None of the
options feel quite right, but that seems the least problematic.




On 3 December 2011 16:14, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> On 02/12/2011 19:45, Benedict Elliott Smith wrote:
>
>> Hi,
>>
>> I just made the fairly rookie error of assuming that
>> AsynchronousFileChannel would have an analagous method to
>> FileChannel.transferTo, but unfortunately this appears not to be the case.
>>
>> Is this simply due to a lack of time, or is there some reason why it
>> cannot be incorporated? I have lots of disk to network transfers to
>> perform, and I'd rather not spawn a thread for each, but I'd equally rather
>> not copy the data into a buffer and straight back out again; I'd prefer for
>> the transfer to be straight DMA, with a callback letting me know it
>> happened.
>>
>> Are there any plans for this to be supported at any point in the future?
>> Or am I being completely retarded and simply missing the already present
>> functionality? I've searched the obvious places for information but so far
>> no luck, and no discussion of it I could find on the mailing lists.
>>
>> Any light you can shed would be appreciated...
>>
>> Cheers,
>>
> Yes, just lack of time and clearly desirable to be have an asynchronous
> transferTo method. The interesting question is whether the target channel
> (or source in the case of a transferFrom) is a synchronous or asynchronous
> socket channel. For now I'm not aware of anyone working on adding this but
> clearly something desirable to add at some point.
>
> -Alan
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20111205/7d1bed62/attachment.html 


More information about the nio-dev mailing list