Matthew,
You are *not* the first person to do this, which is exactly why we are
telling you that you should not make the assumption of destruction
order, we have been bitten by this as well.
Take a look at Devel::GlobalDestruction (which Class::MOP uses, so you
already have it loaded), it will allow you to determine within your
DEMOLISH sub if you are within the scope of Perl's global destruction.
Once you know this, then you can likely just return from your DEMOLISH
method since Perl will automatically clean up all your resources
anyway you won't need to care about ordering.
- Stevan
On Apr 7, 2009, at 11:26 AM, Matthew Persico wrote:
More experimentation is in order. Even if multiple objects inherit
from the same parent, you would think that you would get different
instances and copies of metadata. I cannot be the first person to do
this with moose.
On 4/7/09, Dave Rolsky <auta...@urth.org> wrote:
On Mon, 6 Apr 2009, Matthew Persico wrote:
Do I have the diagnosis right? Here are the relevent parts of the
modules. Now, I know that I really don't need these DEMOLISH subs,
but
even so, they should work, right? I would think that the destruct
sequence would be
LTH::Message::ETN
then, in any order
LTH::Message
LTH::Mqueue
LTH::Config
and finally
LTH
Is this a bad assumption?
Yes, it is a bad assumption.
During global destruction, the order of object destruction is
essentially
random.
One possibility is to try to use an END block to implement some of
the
destruction behavior, but I don't know where you'd put it, or how
it would
access the objects you want to access.
Another possibility is just to give up and not try to do anything
during
global destruction. You can use the Devel::GlobalDestruction module
to
check if you are in global destruction.
Note that this has nothing to do with Moose. This is an issue with
the
Perl interpreter.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/
--
Sent from my mobile device
Matthew O. Persico