Thread: Re: [tcljava-user] JACL eval cancellation
Brought to you by:
mdejong
From: Wei D. <wd...@fn...> - 2007-02-19 07:49:29
|
Hi Mo, Just got a chance to try it out, it seems that the cancellation only takes effect for a loop, so the following case did not work: 1. Cancellation of single command such as After 10000 did not work. 2. Cancellation of a proc: if the proc contains a loop ( I tried while loop ), it will break out of the while loop and return from the proc immediately, but if there is no while loop, it will continue executing all the remaining statement/command in the proc as if there is no cancellation. 3. Why TclEvent.sync() API implementation eats InterruptedException : while (!isProcessed) { try { wait(0); } catch (InterruptedException e) { continue; =20 } } Are those known issues/limitations or am I missing something here? Thanks a lot for your advice Wei -----Original Message----- From: tcl...@li... [mailto:tcl...@li...] On Behalf Of Mo DeJong Sent: Tuesday, February 06, 2007 6:18 PM To: tcl...@li... Subject: Re: [tcljava-user] JACL eval cancellation Wei Dai wrote: > > HI, > > =20 > > Is it possible that an eval command can be cancelled during its=20 > execution? It does not seem to have any API to do this, but I wonder=20 > if there is way to achieve this in the current JACL implementation,=20 > e.g Can I use Interp.setInterrupted to achieve this? > > =20 > Yes, please read: http://tcljava.cvs.sourceforge.net/*checkout*/tcljava/tcljava/docs/Topic s/SetInterrupted.html Mo DeJong ------------------------------------------------------------------------ - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 _______________________________________________ tcljava-user mailing list tcl...@li... https://lists.sourceforge.net/lists/listinfo/tcljava-user |
From: Mo D. <mo...@mo...> - 2007-03-15 00:37:06
|
Wei Dai wrote: > > Hi Mo, > > Just got a chance to try it out, it seems that the cancellation only > takes effect for a loop, so the following case did not work: > > 1. Cancellation of single command such as After 10000 did not work. > 2. Cancellation of a proc: if the proc contains a loop ( I tried > while loop ), it will break out of the while loop and return from the > proc immediately, but if there is no while loop, it will continue > executing all the remaining statement/command in the proc as if there > is no cancellation. > This is not a bug, it is likely caused by a race condition. The cancel check happens after an eval() operation is done. See when checkInterrupted() in invoked in Interp.java. It sounds like this exception check happens later than you expect in the script. It has nothing to do with loop commands, it has to do with when an eval() operation ends. > 3. Why TclEvent.sync() API implementation eats > InterruptedException : > > * while* (!isProcessed) { > > * try* { > > wait(0); > > }* catch* (InterruptedException e) { > > continue; > > } > > } > > Are those known issues/limitations or am I missing something here? > A Jacl interp uses TclInterruptedException, the InterruptedException above is a Java primitive class that has nothing to do with this Jacl feature. cheers Mo |
From: Wei D. <wd...@fn...> - 2007-03-15 01:07:53
|
HI Mo, Thanks for the response. I did debug the program and it seems that when interp.eval(script) is invoked, JACL will parse it and call its internal eval with parsed body and the only time it checks for the interrupted flag is when that eval completes. When it eval a loop, the body of the loop is being eval separated from the loop condition, that is why cancel would work as it would detect the flag after one iteration of eval is done. It also means that cancellation of a single command won't work. Like if you call eval with 'after 30000' and you set cancel after eval has been started, cancel will not have any effect since it will not check until the eval of the AfterCmd completes. The AfterCmd code specifically ignores the interrupted exception, which I do not quite understand. Also TclEvent.sync has a wait(0) with a while loop and also ignores the interrupted exception, if you are doing a event.sync, your eval will never return when cancel occurs! Why do a lot of places specifically ignore the interrupt? Was it a specific design decision to NOT to support single eval command cancellation? Thanks, Wei -----Original Message----- From: tcl...@li... [mailto:tcl...@li...] On Behalf Of Mo DeJong Sent: Wednesday, March 14, 2007 4:37 PM To: A list for users of tcljava Subject: Re: [tcljava-user] JACL eval cancellation Wei Dai wrote: > > Hi Mo, > > Just got a chance to try it out, it seems that the cancellation only=20 > takes effect for a loop, so the following case did not work: > > 1. Cancellation of single command such as After 10000 did not work. > 2. Cancellation of a proc: if the proc contains a loop ( I tried=20 > while loop ), it will break out of the while loop and return from the=20 > proc immediately, but if there is no while loop, it will continue=20 > executing all the remaining statement/command in the proc as if there=20 > is no cancellation. > This is not a bug, it is likely caused by a race condition. The cancel=20 check happens after an eval() operation is done. See when checkInterrupted() in invoked in Interp.java. It sounds like this=20 exception check happens later than you expect in the script. It has nothing to do with loop commands, it has to do=20 with when an eval() operation ends. > 3. Why TclEvent.sync() API implementation eats=20 > InterruptedException : > > * while* (!isProcessed) { > > * try* { > > wait(0); > > }* catch* (InterruptedException e) { > > continue;=20 > > } > > } > > Are those known issues/limitations or am I missing something here? > A Jacl interp uses TclInterruptedException, the InterruptedException=20 above is a Java primitive class that has nothing to do with this Jacl feature. cheers Mo ------------------------------------------------------------------------ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V _______________________________________________ tcljava-user mailing list tcl...@li... https://lists.sourceforge.net/lists/listinfo/tcljava-user |
From: Mo D. <mo...@mo...> - 2007-03-15 21:29:56
|
Wei Dai wrote: > > Also TclEvent.sync has a wait(0) with a while loop and also ignores > the interrupted exception, if you are doing a event.sync, your eval > will never return when cancel occurs! > > Why do a lot of places specifically ignore the interrupt? > Wei, this is from my previous email: > A Jacl interp uses TclInterruptedException, the InterruptedException above is a Java primitive class > that has nothing to do with this Jacl feature. cheers Mo DeJong |