%3 ::nsshell::CurrentThreadHandler ::nsshell::CurrentThreadHandler _eval autocomplete completion_elements context require eval heartbeat info_complete init ::nsshell::Handler ::nsshell::Handler ::nsshell::CurrentThreadHandler->::nsshell::Handler ::nsshell::KernelThreadHandler ::nsshell::KernelThreadHandler dropKernel eval init useKernel ::nsshell::KernelThreadHandler->::nsshell::Handler ::nx::Object ::nx::Object __default_accessor __default_method_call_protection __object_configureparameter __resolve_method_path contains copy delete object method delete object property delete object variable destroy_on_cleanup info info info lookup parameters info lookup slots info lookup syntax info lookup variables info object method args info object method body info object method callprotection info object method debug info object method definition info object method definitionhandle info object method deprecated info object method exists info object method handle info object method origin info object method parameters info object method registrationhandle info object method returns info object method submethods info object method syntax info object method type info object slots info object variables info variable definition info variable name info variable parameter move object alias object forward object method object property object variable private protected public qn require namespace require object method require private object method require protected object method require public object method serialize ::nsshell::Handler->::nx::Object

Class ::nsshell::KernelThreadHandler

::nsshell::KernelThreadHandler[i] create ... \
           [ -kernel (default "") ] \
           [ -kernels (default "") ] \
           [ -supported:1..n (default "eval dropKernel") ]

Defined in /usr/local/ns/tcl/nsshell/shell.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nsshell::Handler[i]
::nx::Class create ::nsshell::KernelThreadHandler \
     -superclass ::nsshell::Handler

Methods (to be applied on instances)

  • dropKernel (scripted, public)

     <instance of nsshell::KernelThreadHandler[i]> dropKernel name

    Delete a kernel in memory. This method actually deletes the interpreter used for the kernel.

    Parameters:
    name (required)

    Testcases:
    No testcase defined.
    if {$name in ${:kernels} && $name ne ""} {
        ns_log notice "dropKernel: drop kernel '$name'"
        #
        # Delete interpreter
        #
        kernels do [list interp delete $name]
        #
        # Remove name from the kernels list
        #
        set posn [lsearch -exact ${:kernels} $name]
        set list [lreplace ${:kernels} $posn $posn]
    } else {
        ns_log notice "dropKernel: No kernel named '$name' defined."
    }
  • eval (scripted, public)

     <instance of nsshell::KernelThreadHandler[i]> eval arg kernel \
        channel

    Evaluate the command provided by "$arg" in the specified kernel.

    Parameters:
    arg (required)
    kernel (required)
    channel (required)

    Testcases:
    No testcase defined.
    debug "[current class] eval <$arg> <$kernel>"
    :useKernel $kernel
    if {$kernel ne ""} {
        set cmd [list interp eval $kernel $arg]
    } else {
        set cmd $arg
    }
    debug "[current class] executes <kernels do $cmd>"
    try {
        set info [list status ok result [kernels do $cmd]]
    } on error {errorMsg} {
        ns_log warning "nsshell: kernel eval returned error <$errorMsg$::errorInfo"
        set info [list status error result $errorMsg]
    }
    return $info
  • useKernel (scripted, public)

     <instance of nsshell::KernelThreadHandler[i]> useKernel name

    Create or use the named kernel. If the kernel does not exist, create it new by creating an slave interpreter.

    Parameters:
    name (required)

    Testcases:
    No testcase defined.
    if {$name ni ${:kernels} && $name ne ""} {
        ns_log notice "Kernel thread creates kernel (= interp) '$name'"
        kernels do [list interp create $name]
        # autoload nx, should be generalized
        kernels do [list interp eval $name {
            package require nx
        }]
        lappend :kernels $name
    }