Class ::nsshell::THREAD

::nsshell::THREAD[i] create ... \
           [ -cmd:required cmd:required ] \
           [ -recreate:boolean recreate:boolean ] \
           [ -tid tid ]

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

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nx::Object[i]
::nx::Class create ::nsshell::THREAD \
     -superclass ::nx::Object

Methods (to be applied on instances)

  • do (scripted, public)

     <instance of nsshell::THREAD[i]> do cmd

    Execute the provided cmd in the slave thread. If the thread does not exist, create it.

    Parameters:
    cmd (required)

    Testcases:
    No testcase defined.
    #ns_log notice "THREAD [self] received <$cmd>"
    if {![nsv_exists [current class] [self]]} {
        #
        # lazy creation of a new slave thread
        #
        thread::mutex lock ${:mutex}
        if {![nsv_exists [current class] [self]]} {
            set :tid [::thread::create]
        }
        nsv_set [current class] [self${:tid}
    
        set initcmd ${:initCmd}
        ::thread::send ${:tid} $initcmd
        set :tid [nsv_get [current class] [self]]
        thread::mutex unlock ${:mutex}
    } else {
        #
        # slave thread is already up and running
        #
        set :tid [nsv_get [current class] [self]]
    }
    ns_log notice "calling [current class] (${:tid}, [pid]) $cmd"
    thread::send ${:tid} $cmd