In AOLserver 4.5 the following new Tcl APIs are provided:

   "ns_for"
   "ns_foreach"
   "ns_while"
   "ns_loop_ctl"

The usage is exactly the same as the "nsloopctl" module I checked in, and which I documented in the README file. The only difference between the two is that "nsloopctl" will actually "redefine" Tcl's "for", "foreach", and "while" commands, while the new AOLserver 4.5 APIs require you to use the new commands explicitly. Forgot we had added it to the core, so I'll remove - sorry about the confusion. ;-)

Here's a quick example:

   server1:nscp 4> ns_thread begindetached "while 1 {ns_sleep 1:0}"

   server1:nscp 5> ns_loop_ctl list

   server1:nscp 6> ns_thread begindetached "ns_while 1 {ns_sleep 1:0}"

   server1:nscp 7> ns_loop_ctl list
   0

   server1:nscp 8> ns_loop_ctl info 0
   0 41973248 1149519792:592471 9 running {ns_while 1 {ns_sleep 1:0}}

   server1:nscp 9> ns_loop_ctl pause 0
   1

   server1:nscp 10> ns_loop_ctl resume 0
   1

   server1:nscp 11> ns_loop_ctl cancel 0
   1

   server1:nscp 12>  ns_loop_ctl list

If you want to gather statistics about existing "for", "foreach", and "while" loops, simply rename those commands and have them instead point to the new commands:

for -> ns_for
foreach -> ns_foreach
while -> while

Hope that helps!

- n


[EMAIL PROTECTED] wrote:
Nathan,

This is interesting, but I thought I saw this code as part of 4.5, wasn't this committed earlier?

Are you going to post examples? It is hard to tell exactly what this does differently than the tcl commands. At some point a tcl error isn't appended to the result, but I don't know if this is your code of copied from tcl.

How is it possible to pause/resume a loop?

tom jackson

On Monday 05 June 2006 06:20, Nathan Folkman wrote:
On the heels of the "Zippy2" code release, I've also committed a new
module called "nsloopctl". This module redefines Tcl's "for", "foreach",
and "while" commands to allow
both the gathering of statistics about each loop, and also to provide a
mechanism to pause, cancel, and resume a particular loop.

http://aolserver.cvs.sourceforge.net/aolserver/nsloopctl/

This module has shown itself to be quite useful as both a debugging
tool, and the performance hit is slight enough that you should be able
to run in a production environment as well.

Hopefully someone will find this useful! Enjoy! ;-)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to