Re: Thread-safe perl XS modules
[email protected] (Dean Arnold) Tue, 26 Jun 2007 11:52:26 -0700
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <[email protected]> |
Thomas Busch wrote: > ah I see. I just had a look at the threads.xs file. > So basically perl_clone triggers a call to the CLONE() > method of all variables ? > > Thomas. > *If* they have a CLONE() method, yes. Otherwise, it just makes a copy of the variable (including contents of arrays/hashes), fixing up references as it goes. So if your object has a field thats actually a ptr to a C++ object, it gets copied as a scalar. Which may cause your DESTROY() to invoke the C++ object's destructor twice, or reference a dead ptr the 2nd time DESTROY() is called. Note that a thread::shared objects don't get cloned (tho the thread-private "proxy" wrapper does), and its DESTROY won't get called until the last referencing thread exits. Dean Arnold Presicient Corp.