Ns eval

From AOLserver Wiki
Jump to navigation Jump to search

Man page: http://aolserver.com/docs/tcl/ns_eval.html


NAME

ns_eval - Evaluate tcl in multiple interpreters

SYNOPSIS

ns_eval ?-sync? ?-pending? ?args?

DESCRIPTION

This command causes args to be sourced as a script in all Tcl interpreters for the current virtual server. Normally, the ns_eval is asynchronous and the script isn't immediately evaluated in the other interpreters until their next atalloc event. If the -sync option is specified, ns_eval blocks until all servers have executed the script.
The -pending flag, which cannot be specified with any other flags or args, returns a list of the scritps still waiting to be evaluated in the various interpreters.
NOTE: This command is currently implemented in Tcl, in the source file nsd/init.tcl.
ns_eval is designed to work whether you pass your script as one argument or many arguments. In order to accomplish this, the arguments are passed through:
   uplevel 1 [eval concat $args]
which means that there are two rounds of concat behavior, unlike a straight eval. See the example below of unsetting a global variable to see how this can play out.

EXAMPLES

   # Set a global variable accessible from all interpreters
   ns_eval set myGlobal 1
   # Create a proc accessible from all interpreters, and wait
   # for it to be define in all of them before returning
   ns_eval -sync proc doSomething {args} { # do something }
   # Get the list of pending scripts to be eval'd
   ns_eval -pending
   # Unset an array variable in all interpreters.
   ns_eval {{if {[info exists myGlobal]} {unset myGlobal}}}
   # The code that ends up being evaluated in each interpeter is:
   # if {[info exists myGlobal]} {unset myGlobal}    

SEE ALSO

ns_cleanup, ns_ictl, ns_init, ns_markfordelete, ns_reinit, nsproxy

-