[Xotcl] Object destruction on exit

Gustaf Neumann neumann at wu-wien.ac.at
Thu Feb 2 23:33:36 CET 2006


Kristoffer Lawson schrieb:

> When XOTcl exits, it seems that the [destroy] method is called on all  
> objects. The first question is whether this is wise .. possibly. 


well, it was some work to do so, and i think this is important from the 
oo-point-of-view.
If one allocates "external resources" (e.g. temp-files, register on a 
whiteboard, etc)
and deallocates these resources in a destructor, the deallocation should 
certainly
happen, when the program exists gracefully.

> The  problem is I would like to build a transparent layer for 
> persistence  storage which could be applied to a wide range of 
> applications. The  problem naturally is that the objects in the 
> persistence storage get  destroyed when the application exits :-)

a strong coupling of  the destruction of an xotcl object with its 
persistent representation
is often not a good idea.  For example, in the aolserver, persistent 
objects will be used
in connection threads, which are created/terminated based on demand.

note, that also the creation of objects is in the persistent situation 
different. When one creates
a new object, it is expected to be in a freshly initialized state. In 
the persistent case,
you might want do decide, wether you want a fresh persistent object, or 
a refetched
object from the last checkpoint. I use normally a fetch and delete method.
You can still call e.g. delete from the destructor if you need it....

-gustaf

>
>            /  http://www.fishpool.com/~setok/
>
> _______________________________________________
> Xotcl mailing list
> Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl




More information about the Xotcl mailing list