According to perlmod:
This provides a simple mechanism for making a module threadsafe; just add sub CLONE_SKIP { 1 } at the top of the class, and DESTROY() will now only be called once per object. Of course, if the child thread needs to make use of the objects, then a more sophisticated approach is needed.
Are you aware of a "more sophisticated approach"?
Ie. Is there some technique or trick to allow a module to discover which of its blessed refs have been cloned (and which not) so as to allow it to ignore/defer DESTROY requests until the last copy goes out of scope?
Seems that if CLONE_SKIP was called each time a reference for a package it cloned -- and passed in a copy of the reference -- it would be possible for packages to do their own reference counting and thus avoid corrupting the internals of cloned objects -- by freeing memory associated with a cloned reference when one copy of it goes out of scope (when a thread ends) -- as I did.
In reply to Re^2: [XS] Cloning is corrupting my privates.
by BrowserUk
in thread [XS] Cloning is corrupting my privates. (Solved!)
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |