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

Re: p5p summary: Improving threads::shared ?

Thread Previous | Thread Next
From:
Dean Arnold
Date:
May 6, 2008 14:00
Subject:
Re: p5p summary: Improving threads::shared ?
Message ID:
4820C6F5.1070908@presicient.com
Dean Arnold wrote:
> Jerry D. Hedden wrote:
>> Conceptually, I think it would require keeping a weak
>> reference of each private SV associated with a shared SV.
>> This would need to be done on a per-thread basis.  Then when
>> a thread tries to reference a shared SV, a lookup would be
>> made to see if a private SV already exists (and still
>> exists) for that thread.  If so, that is returned (and the
>> ref count of the weak ref is incremented?).  If not, a new
>> private SV is created, and a weak ref to it is appropriately
>> stored.
>>
>> Is this a logical approach?  If so, is it doable?
>>
> 
> For threads::shared, the only solution I can think of is
> adding a fieldhash to the thread-private my_ctx structure
> keyed by the address of the referent variable's
> shared version. Then each attempt to create a new proxy
> would lookup any existing persistent proxy for the shared
> SV, and return it if found (currently, each new reference
> to a shared variable creates a new proxy, which is what causes
> this mess).
> 

I forgot one not-so-minor detail: clone processing
would need to be updated to
detect and replace the fieldhash'd proxies, and
update each SV that invoked the magic dup() method

- Dean

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About