This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic_string atomicity


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!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]