At 1:38 PM +0200 4/11/05, Rafael Garcia-Suarez wrote:
Dave Mitchell wrote:
 On Wed, Apr 06, 2005 at 11:02:49PM -0400, Stas Bekman wrote:
 > 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').

 After some chatting with Stas, we've come to the conclusion that what he
 needs most is the ability, on a per-class basis, to disable the cloning of
 objects; ie in the child thread, each SvOBJECT() SV becomes an SVt_NULL
 SV. This avoids all the problems of multiple calls to DESTROY, multiple
 pointers to C structures etc.

 The question then is how to flag a particular class (and its subclasses)
 as being 'don't clone'.

 The current suggestion is to have a class method called SHOULD_CLONE(),
 and just before creating the new thread, this method is called, once per
 stash, in the context of the parent thread. Any stash which has this
 method and where it returns a false value, will be marked as 'don't clone'
 for the duration of the cloning.

Better suggestions for the technique or the method name are welcome :-)

Why define a method to return a negative value ? DONT_CLONE() that returns true seems more logical.

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

Reply via email to