harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Kleymenov" <kleyme...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Tue, 27 Jun 2006 09:20:07 GMT
Hello,

> Paulex Yang wrote:
>
> IIRC, Archie's suggest #3 is about select interruption, so what's your
> suggestion to implement the blocking I/O interruption?

Use non-blocking calls instead of blocking ones. There are some approaches
to implement non-blocking I/O over the blocking (in the native code of course).
Although there can appear some cases where it will be impossible to do.

> And even another time, I think maybe I need to emphasize again that the
> AbstractInterruptibleChannel/AbstractSelector must encapsulate the
> machinery about the interruption, so that it is easy for Harmony user to
> create its own interruptible channel.

Agree! Moreover, AbstractInterruptibleChannel/AbstractSelector is only
place for it.

>> I doubt that just calling of this methods will made blocking
>> operations interruptable. I.e. we should have interruption support in
>> [interruptable] blocking operation anyway.
>
> I think what Andrew said come from Java spec? Why you think the proposal
> cannot work?

I do not think it cannot work. It's fine solution and it will do all
the necessary work!
But it needs changes in VMI spec and I tried to discuss approach which does
not need such changes.

> Andrew Zhang wrote:
>
>> Sorry if I missed something.
>
> Any better solution is highly appreicated, Thanks!

I can propose another way: begin() method creates new thread listening
for Thread.curentThread().isInterrupted() status and if it becomes
true, it just calls close() method, triggers the state of the channel
as ClosedByInterruptException, and exits. The end() method just stops
this additional thread (if it was not stopped after the blocked Thread
had been interrupted) and, if necessary, throws appropriate exception.

No VMI changes are needed, but there will be additional thread between
begin() - end() calls. This thread will sleep between isInterrupted() checks
and will not take much computational resources.


Thank You,
Alexander

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message