On 12/3/2003 3:06 PM, Stas Bekman wrote:
Obviously there is a solution to this problem. Enter the magic CLONE function called when a new thread is spawned (perl_clone is called). If a package defines this function, perl will call it. When CLONE is called Perl has already cloned $y. So what you need to do is to go and change $y's guts to point to a new C struct, initialized from the original C struct. But without changing $y, i.e. it's external appearance must not change. Only the IV slot needs to be changed. So here is where my question comes into the picture. How to call that method that will substitute the IV slot without changing the object. It's going to be used by many XS modules so we'd better choose a good name for it so we can all talk about the same method.

I chose the name 'possess' as if the object 'being possessed by some evil spirit'. Remember that the external object must stay the same (since it lives in the user's space, e.g. script and we can't touch it).

Liz wrote a module Thread::Bless which provides a framework for this issue, and she called this method 'fixup'.

Now that hopefully you understand the problem and what the method is trying to achieve, Liz and I are trying to get more ideas from you.

I'm a C++ guy, so this kinda makes me think of auto_ptr<>'s and their reset method except that doesn't actually copy... actually this sounds more like a copy constructor; what about copy_construct() ??? But then I like possess also since it has that connotation of something magic and scarry going on... better double check those docs before invoking a possession.


thesaurus says possess: bedevil, diabolize. ;)

Regards,
Randy.



Reply via email to