basic_string atomicity

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jan 5 22:00:00 GMT 2012


On 5 January 2012 21:28, Jonathan Wakely wrote:
>>
>> What consistency model does libstdc++ require?  __sync_fetch_and_xxx
>> has become more heavy-weight and even the earlier memory model
>> probably was unnecessarily expensive for its usage in libstdc++ based
>> on our analysis for POWER.
>
> std::string is required by C++11 to be not reference-counted, so
> changing the details of the ref-counted implementation isn't a high
> priority if we're going to replace it anyway (although we will retain
> a ref-counted COW string as __gnu_cxx::__rc_string.)
>
> I'm not sure what the memory ordering requirements are for
> std::string, I think decrementing the count to zero needs to
> synchronise with deallocating the memory, but I'm not sure about
> increments.

I think decrementing the refcount in _M_dispose() should be acq_rel,
but as you suggested the increment in _M_ref_copy only needs to be
acquire. I think.  Check that with an expert though, I'm not
confident!



More information about the Libstdc++ mailing list