- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsshell::THREAD
::nsshell::THREAD create ... \
[ -cmd:required cmd:required ] \
[ -recreate:boolean recreate:boolean ] \
[ -tid tid ]
Defined in /usr/local/ns/tcl/nsshell/shell.tcl
Class Relations
::nx::Class create ::nsshell::THREAD \ -superclass ::nx::ObjectMethods (to be applied on instances)
do (scripted, public)
<instance of nsshell::THREAD> do cmdExecute 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
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables