No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] setExitHandler & threads
From: Scott Gargash <scottg_at_atc.creative.com>
Date: Tue, 15 Aug 2006 08:46:22 -0600
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
Date: Tue, 15 Aug 2006 08:46:22 -0600
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