[cpp-threads] A question about N2153

Chris Thomasson cristom at comcast.net
Wed Jan 17 20:45:48 GMT 2007


----- Original Message ----- 
From: "Alexander Terekhov" <alexander.terekhov at gmail.com>
To: "C++ threads standardisation" <cpp-threads at decadentplace.org.uk>
Sent: Wednesday, January 17, 2007 11:47 AM
Subject: Re: [cpp-threads] A question about N2153


> On 1/17/07, Peter Dimov <pdimov at mmltd.net> wrote:
>> What is the reference implementation of acquire_fence for x86, SPARC RMO,
>> PowerPC, IA-64? I'm guessing (no op), #LoadLoad | #LoadStore, lwsync, mf.
>>
>> If we take the example:
>>
>> if( fetchadd_release( &ref_count, -1 ) == 1 ) // old value
>> {
>>    acquire_fence();
>>    destroy_object();
>> }
>
> This example is driving at std::tr1::shared_ptr's "strong" count
> decrement (a decrement that is a release when the new value is nonzero
> and an acquire when the new value is zero with a requirement to
> actually store 0 for increment_if_not_zero()  std::tr1::weak_ptr's
> logic to work).

Are there any plans to make shared_ptr atomically thread-safe like Java 
references? I have a full-blown prototype of such an algorithm that 
shared_ptr can use on the x86 here:

http://appcore.home.comcast.net/vzoom/refcount/

In an ideal world, I could use the memory model you guys are all working on 
to create the reference counting algorithm presented above. 




More information about the cpp-threads mailing list