nsshell::THREAD method do (public)

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

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

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

Parameters:
cmd (required)

Testcases:
No testcase defined.
Source code:
#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
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: