develooper Front page | perl.ithreads | Postings from May 2008

Re: p5p summary: Improving threads::shared ?

Thread Previous | Thread Next
Dean Arnold
May 4, 2008 12:06
Re: p5p summary: Improving threads::shared ?
Message ID:
Dean Arnold wrote:
> Jerry D. Hedden wrote:
>> Dean Arnold wrote:
>>>  I've been pouring over the p5p archives trying to find
>>>  what the subject p5p summary item is about, but wo/ any luck.
>>>  Can someone point out the relevent thread title, or maybe
>>>  summarize what "threads::shared could share aggregates
>>>  properly with only Perl level changes to"
>>>  means ?
>> It means that something like this would DWIM:
>>     my $x : shared;
>>     $x = [ { 'complex' => 'aggregate' }, [ qw/ currently not sharable 
>> / ] ];
> <snip/>
>> Thread::Queue has the Perl code needed for making 'complete'
>> shared clones of data structures (i.e., all parts whether
>> shared or not are cloned).  Tweaking it to not clone already
>> shared portions is trivial.
> I see someone's been busy ;^)
> Alas, there's one catch that the current T::Q implementation
> doesn't cover: recursive structures:
> (Using AS Perl 5.8.8, WinXP, T::Q 2.06)


> OTOH, if a bitflag could be grabbed
> somewhere to do a mark/sweep, this might be solvable
> Or maybe using a fieldhash to key the original ref thats
> being cloned, do a quick lookup, and if it exists, then skip it


Momentary insanity:
Why not reuse the existing perl_clone code ?
Assuming an appropriate entry point could be
found *and* perl_clone can be fooled into
using the shared global interpretter instead
of creating a new interpretter, it should be
possible to do a complete clone wo/ circular issues.
And it would presumably support creation of
shared filehandles.

OTOH, the last time I tried to decipher perl_clone(),
I ended up w/ a 3 day headache, so it may be

- Dean

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About