|
From: Ken A. <kan...@bb...> - 2004-03-01 23:28:54
|
My experience with JScheme is that calling a method to check if you've been interrupted is too costly. So i esentially do
if (INTERRUPTABLE) interruptCheck();
interruptCheck() looks like:
/** Maybe interrupt this thread of execution. **/
public static void interruptCheck() {
if (INTERRUPTABLE && Thread.currentThread().interrupted()) {
INTERRUPTABLE = false;
throw new JschemeThrowable("Execution was interrupted.");
}
}
To interrupt a thread you call the static method:
/** Interrupt execution on thread <tt>t</tt>. **/
public static void interrupt (Thread t) {
INTERRUPTABLE = true;
t.interrupt();
}
You may need something different in BeanShell.
We put the INTERRUPTABLE check in the main evaluator loop, at function calls, and in 14 other places for built in procedures - while loops for things like appending or mapping over lists which can be long. But you can get along with just the check in the evaluator to start with.
k
At 04:20 PM 3/1/2004 -0600, Pat wrote:
>On Mon, Mar 01, 2004 at 02:09:38PM -0800, Shankar Unni wrote:
>>
>> That might not work reliably either. Consider (for the sake of form):
>>
>> while (true) {
>> try {
>> while (true) ;
>> } catch (Exception e) {}
>> }
>>
>> Now *that*'s practically uninterruptible, unless you catch it in the tiny
>> windows outside the try block.
>
>Yah, that's what I meant by adding the hooks to our looping control structures
>as well as the main loop. There are only a few places necessary to cover all
>of those cases, I think...
>
>I'm speaking of script code of course... If Java code does that we're hosed ;)
>
>
>Pat
>
>
>-------------------------------------------------------
>SF.Net is sponsored by: Speed Start Your Linux Apps Now.
>Build and deploy apps & Web services for Linux with
>a free DVD software kit from IBM. Click Now!
>http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
>_______________________________________________
>Beanshell-users mailing list
>Bea...@li...
>https://lists.sourceforge.net/lists/listinfo/beanshell-users
|