[Xotcl] setExitHandler & threads
Scott Gargash
scottg at atc.creative.com
Fri Aug 11 04:49:54 CEST 2006
I've run into an interaction with threads and the XOTcl exit handler that I don't understand.
I create a thread from within an object, and release that thread in the object's destructor. If I
destroy the object directly, everything's fine, but if I destroy the object through "Object
setExitHandler", I get an error. Am I treading into undefined behavior? Is there well-defined way
to shut down multiple threads?
Scott
Here's some sample code:
package require XOTcl
package require Thread
namespace import {xotcl::*}
Class A
A instproc init {} {
my set tid [thread::create [subst -nocommands {
set ::auto_path [list $::auto_path]
package require XOTcl
namespace import {xotcl::*}
Object b
thread::wait
}]]
}
A instproc destroy {args} {
thread::send [my set tid] {b destroy}
thread::release [my set tid]
next
}
A a
if {0} {
# This gives an error
xotcl::Object setExitHandler {a destroy}
} else {
# this works
a destroy
}
exit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20060810/7ae6ad0b/attachment.html
More information about the Xotcl
mailing list