Mike Pomraning wrote:
> I think it'd be a good idea formally to document/expose
> threads::shared::_refcnt, though perhaps without the leading
> underscore.
>
> When DESTROYing a share()d (and typically XS-backed) object that
> represents some underlying system resource, one wants to
> release/free/close/dismiss the system resource only on the final
> DESTROY, regardless of thread.  Perl's filehandles under ithreads
> already behave like this without share()ing, but this behavior is
> difficult to emulate with user-defined objects.  ( See also
> http://perlmonks.org/?node_id=632731 )
>
> Of course, one can do this sort of bookkeeping one's self, but, AFAIK,
> threads::shared is already doing the bookkeeping with _refcnt.
>
> Anyone have comments or a better way?

Thanks for this info.  For Object::InsideOut, I was tracking
thread usage for shared objects.  I changed the code to
using _refcnt() (i.e., don't destroy if _refcnt($obj) > 1),
and it worked.  It also reduced the code by about 3 dozen
lines of code.

I'll make a change to threads::shared to expose _refcnt() as
refcnt().  If anyone would like to suggest some description
for the POD, I'd be happy to consider it.  Thanks.

Reply via email to