Re: threads, XSUB allocated memory, destructors, destruction



Greetings from the original poster
> Thanks for taking the time to provide that example. That about wraps it up
> for me ..... wonder how the op is getting on with this :-)

I can tell you... Not very happy.
Using CLONE_SKIP() does what it should. It stops you being
destroy()ed. Unfortunately, "man perlmod" says your objects
"will be copied as unblessed, undef values" and "if the
child thread needs to make use of the objects, then a more
sophisticated approach is needed.
OK.
Maybe I should write my own CLONE(), although this is a bad
idea. Perldoc Threads::shared says that "Currently CLONE is
called with no parameters other than the invocant package
name". This means you can't get to the address you need to do the
copying. It is a catastrophically ugly approach to a large amount
of data which should be shared since it is passed to threads for
use in some calculations.

We are dealing with arrays of blessed objects. They should
be shared between threads, but then one hits the problem
that ""bless" is not supported on shared references. In other
words, if one has a reference to a 2D array of blessed objects
and says p $$coords[0][0], you get something like
MyPtr=SCALAR(0x85efe8c). If you then mark it as shared,
"share $coords", and try the print statement, you are bluntly
told, "Invalid value for shared scalar at ...".

So, that is the answer to the question, "how is the op getting
on with this".
Andrew
.