harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject Re: [Fwd: [classlib][NIO|VMI]Interruptible channel implementation - how to interact with Thread?]
Date Wed, 21 Jun 2006 05:47:29 GMT
Archie Cobbs wrote:
> Paulex Yang wrote:
>>> OK, this is nice and simple.. installing an interrupt action is a clean
>>> and Java-centric way to make the handling of interrupts explicit. It 
>>> may
>>> be technically unnecessary (if POSIX signals were available) but has
>>> the advantage of being less tied to the O/S and VM internals.
>> Great, so may I assume you agree with the VMI modification to add 
>> Thread.setInterruptAction()?
>
> Yes, looks good.
Great! So if no one objects, I will raise JIRA and provide the patch for 
AbstractInterruptibleChannel, but I have no idea how to patch the 
VMI/kernel class(any committer kindly help?).
>
> I'm still curious what mechanism will be used to wakeup blocked threads
> though.
I thought I've described the solution in my first post triggering this 
thread, but I'm sorry if it's confusable. Basically the thread is waken 
up by closing the I/O channel in another thread. Please see below for 
details:

The AbstractInterruptibleChannel's begin()/end() is probably like:

public void begin(){
    interruptActionSetter.execute(Thread.currentThread(), new 
Object[]{new Runnable(){
       public void run(){           
          AbstractInterruptibleChannel.this.close();
       }
    }});
}

public void end(boolean complete) throws XXXXException{
    interruptActionSetter.execute(Thread.currentThread(), new 
Object[]{null});
    if(interrupted) blabla
    else if(closed && !completed) blabla
    else blabla  
}

And when Thread.interrupt() executes the interruptAction and closes the 
channel, generally the blocking I/O operation will return with an error 
code, and if Harmony user implements a subclass of 
AbstractInterruptibleChannel, he is required by spec to implement 
implCloseChannel(which is invoked by close()) in similar way, in both 
cases, the thread is waken up as by product.

The blocking select is waken up in similar way by invoke wakeup() in 
interruptAction.
>
> -Archie
>
> __________________________________________________________________________ 
>
> Archie Cobbs      *        CTO, Awarix        *      
> http://www.awarix.com
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Paulex Yang
China Software Development Lab
IBM



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