Elizabeth Mattijsen wrote:
[...]
Hmmm... wouldn't it be handier to have a method CLONED() which is called for each object (and with the object as parameter) and which is expected to return a cloned objects, ready to be used inside the thread? If it returns undef, then the object should not be cloned. If it return an object, then that object should be used inside the thread.

This should give you more flexibility and would allow modules to actually do something sensible with objects to be cloned.

Liz, as I've mentioned in the original post starting this thread, CLONE still sucks and it'd be great to have it working as I've suggested (pass the objects to CLONE as a list or one by one, whatever). So this ideally should be done too, but as I've started implementing it (and it didn't look simple, as it required creating internal %cache of all objects, cpu and memory overhead) I've realised that since mp2 objects can't be cloned anyway, why bother and go through the hoops to undo the damage done by Perl. That's how we came up with the DONT_CLONE idea, so the evil is avoided in first place.


The coolest thing about the DONT_CLONE idea, is that now any CPAN module can be made perl-thread-safe by just adding this method to the class. Granted, the objects won't be cloned (incorrectly) and will be unusable in the threads, unless created there, but it'll prevent all the segfaults and race conditions within XS modules caused by the incorrect cloning.

--
__________________________________________________________________
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