Re: DESTROYing shared objects, finally

[email protected] (Mike Pomraning)
Newsgroups perl.ithreads
Message-ID <[email protected]>
On Thu, 23 Oct 2003, Mike Pomraning wrote:

> [....] suggestions on how I might determine which DESTROY [of a shared,
> blessed ref] is the very last one?

Sorry to reply to my own post, but here's how I've attempted to identify the
last DESTROY of a shared object:

  sub DESTROY {
    return unless threads::shared::_refcnt($_[0]) == 1;
    # if we're here, the shared object is going away for good.
    # time to release system resources, call XS deallocators, etc.
    }
  }

The only other approach I can think of is to do (ser|ted)ious inventorying via
CLONE, DESTROY and constructors, or a wrapped bless.  (I did see the
"[CAUTION] Thread-saving modules" not-a-bug thread from Jul 2002 before my
previous post, but this is not quite the same.)

Multiple destruction of non-shared objects makes sense to me, as each becomes
a thread-local copy.  Multiple destruction of shared objects, however, does
not (though I think I understand the mechanics of why it happens).  Am I
looking at this issue the wrong way?

Regards,
Mike
-- 
Michael J. Pomraning
[email protected]
http://pilcrow.madison.wi.us
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.