AsynchronousByteCharChannel and Timeouts
Alan Bateman
Alan.Bateman at Sun.COM
Sat Aug 1 14:18:47 PDT 2009
Gili wrote:
> :
> I don't understand. Are you talking about adding functionality similar to
> Future.get(long timeout) on top of an existing byte channel? I was talking
> about the different between:
>
> read(ByteBuffer dst, A attachment, CompletionHandler<Integer,? super A>
> handler);
>
> and
>
> void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment,
> CompletionHandler<Integer, ? super A> handler);
>
> As far as I know you can't implement the latter in terms of the former
> because you need to pass the timeout values to the underlying OS. What did
> you mean?
>
You should be able to implement the timed variants using the non-timed
methods when combined with the timer support in java.util.concurrent.
That's what we do in the AsynchronousSocketChannel implementation and
should be applicable to other channel types too. All I was suggesting is
that this might be something useful to add to your library.
-Alan.
More information about the nio-discuss
mailing list