harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Wed, 14 Jun 2006 09:56:05 GMT
Paulex Yang wrote:
<snip>
> Seems Thread's implementation must be aware of what operation it is
> blocking on. So I propose the following solution:
> 
> 1. Add this method to kernel class Thread (in VMI): private void
> setInterruptAction(Runnable action);

...and, reading on, you'll need to add a new field to Thread too to
remember the action?  Though since Thread is in kernel that is the VM's
choice.

> 2. Thread's default value of action is null. Thread's interrupt() method
> will check the action field at first, if it is not null, execute the
> action at first, and then perform the normal interruption.

Requires updating the VMI spec to say that interrupt() must execute the
Runnable action if it has been set (to a non-null value).

> 3. If some interruptible blocking I/O operation is going to happen, then
> invoke this method to current thread like below (probably by reflection):
> 
> Thread.currentThread().setInterruptAction(new Runnable(){
>    public void run(){
>       interrupted = true;
>       AbstractInterruptibleChannel.this.close();
>    }
> });
> 
> 4. It is the AbstractInterruptibleChannel's responsibility to reset
> Thread's interrupt action to null after the blocking I/O operation.

So by default the action is not cleared?  Sounds reasonable.

> 5. The interruption of select operation can be implemented in same way,
> all difference is another Runnable inner class, which invokes selector's
> wake-up.
> 
> comments? ideas?

Sounds ok (but will need a change to the IBM VME | classpathadapter
before you can try it).


Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
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