|
Boost : |
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2020-12-04 19:04:26
On 12/4/20 8:44 PM, Peter Dimov via Boost wrote:
> Andrey Semashev wrote:
>
>> > [*] Incidentally we want to increment with memory order relaxed
>> instead > of acq_rel.
>>
>> This would probably be a good optimization in atomic_count.
>
> atomic_count can't do this because it doesn't have enough knowledge
> about the context in which it's used.
>
> https://github.com/boostorg/smart_ptr/blob/678a544d27d016204c6aed6403b1ffdf0b021d1b/include/boost/smart_ptr/detail/atomic_count.hpp#L33-L43
>
>
> In principle you can use negative values for the count, again destroying
> on zero.
>
> I could have specified ++a to be relaxed, but it is what it is at this
> point.
atomic_count is formally an implementation detail of Boost.SmartPtr, so
you can define it as you see fit. If it is only used as a reference
counter, you could make it increment with relaxed semantics. Or add a
separate member with such behavior (but then the operator++ would become
unused).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk