Randy W. Sims wrote:
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() ???

Thanks, Randy.


I haven't done C++ for a long time, but if I remember correctly copy_construct() is invoked on the existing object and it doesn't modify the original, but returns a new object. Here the situation is different: Perl has already invoked its copy_constructor and gave you the resulting object, so all is left is to copy the C struct and modify the passed object's IV slot. So this is sort of a copy_construct on the guts of the object...

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. ;)

let's call it scary_function() then ;)


% perldoc -f possess
  possess SPIRIT
          this function is NOOP before midnight, but after the midnight
          will make your code do scary things, altering the TIMTOWTDI to
          TIASWTDI (as in There Is A Scary Way To Do It). You must be at
          least 16 years old to use this function.

;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to