[Xotcl] setExitHandler & threads
Scott Gargash
scottg at atc.creative.com
Tue Aug 15 16:46:22 CEST 2006
Scott Gargash schrieb:
>
> 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?
>
the thread and exit code is a tricky and sensitive area, especially if
it is supposed to work with tcl and the aolserver. below is the somewhat
simplified code (btw., your example works on mac os x without a
problem). In general. there is no need to destroy the objects by hand,
since these are destroyed automatically and the appropriate destroy
methods are executed. also, the destroy order is not completely trivial
in order to be able to execute the destroy methods correctly. i would
not do this by hand.
isn't the default beavior sufficient?
Unfortunately, the default behavior is not sufficient. My example was simplified from my real
problem. In the real problem, I have essentially a directed graph of objects that I serialize out
upon destruction. Since the default behavior doesn't destroy objects in a defined order, when the
root object goes to serialize out, some nodes that it needs to serialize may already be destroyed.
This is undesireable.
So I inserted my own exitHandler and that works in a single thread, but when I have multiple
threads, things get confused.
BTW, the failure was on WinXP. Given that the behavior is different on different platforms, it does
seem like I've treaded into undefined behavior. Is there any way to wrangle it back into something
defined?
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20060815/df2aa0f3/attachment.html
More information about the Xotcl
mailing list