On Wed, Apr 06, 2005 at 11:02:49PM -0400, Stas Bekman wrote:
> After numerous hours wasted trying to use CLONE to make the mod_perl 2 API 
> perl-threads safe, I've arrived to a conclusion that it just doesn't work. 
> The only currently available hack of stashing weakened copies of the 
> object in the stash on new(), and then going through that stash on CLONE() 
> and hollowing/cloning/invalidating objects and then on DESTROY cleaning up 
>  each hash entry at at time, is simply too complicated to code, adds a 
> huge overhead CPU and memory-wise, and with 20+ classes with complicated 
> constructors I still get segfaults all over.
> 
> No wonder CPAN's XS modules are mostly non thread-safe.

add "remain" to non thread-safe and I'll completely agree

They're also most not UTF8 safe. It's a side effect of Perl 5.6 changing the
binary API. It's just that at least making them UTF8 safe is easier.

Plus there isn't the joy of shared container objects for Unicode.

> It's time to write CLONE2 which should be a method, identical to DESTROY, 
> which should be called by perl_clone(), when it sees that the 
> object->can('CLONE2').
> 
> Of course for backward compatibility CLONE should stay as it is now.
> 
> What do you think?

Does this differ at all in functionality from the proposal to pass an array
(or arrayref) of all objects of a class as an argument to the CLONE method?

IIRC the ithreads clone code is pretty much already tracking this information.

I thought that there would be problems with subclasses that don't override
the CLONE method, but there isn't - if Bar is a subclass of Foo, then
Foo->CLONE([EMAIL PROTECTED]) is called for all the Foos, and Bar->CLONE([EMAIL 
PROTECTED]) is called
for all the Bars.

Nicholas Clark

Reply via email to