For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2006 > What am I doing wrong with ttrace in my threads









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What am I doing wrong with ttrace in my threads
af300wsm@gmail.com

2006-10-02, 7:06 pm

Hello again,

Ok, I've worked through a number of issues, now I've got one that
evidentally shows that I don't quite understand how to use the ttrace
package. I'm using thread package version 2.6.1 and it didn't have
ttrace built into it so I'm loading it separately. It matters not what
I do, the commands I define while using ttrace::eval don't seem to
propogate to the subordinate threads.

Below is the code to a test script I'm using to "get it right" instead
of trying to get it right in my more complicated script.

lappend auto_path ./lib ;# this is where ttrace is located

package require Thread
package require Ttrace

set cThread {
lappend auto_path ./lib

package require Ttrace

after 2000
for { set i 0 } { $i < 10 } { incr i } {
test
}
}

thread::create $cThread

ttrace::eval {
proc test { } { puts "Hello from thread: [thread::id]" }
}

for { set i 0 } { $i < 10 } { incr i } {
after 1500
test
}

exit 0

Originally, I was calling the ttrace::eval command before defining my
thread and creating it. However, I thought that perhaps the commands
didn't replicate to non-existent threads. So, as you can see from
above, I'm creating the thread before calling ttrace::eval. However,
this still didn't fix the problem. Every time I try to call the test
proc from my child thread, I get "invalid command name" but it works
just find in the parent thread.

I know that the TCL threading model makes a new interpreter, self
contained (mostly), separate from other threads and that standard
procedure definitions don't cross thread boundaries. However, I
thought that the ttrace package was supposed to "fix" this
"deficiency"? So, working under the assumption that ttrace works as
defined, there must be something that I'm doing that is not correct.
Would some kind soul in this group please explain to me where my steps
are faultering?

Thanks,
Andy

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com