Re: p5p summary: Improving threads::shared ?
[email protected] (Dean Arnold) Tue, 06 May 2008 14:00:37 -0700
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <[email protected]> |
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