vendredi 23 janvier 2015

What is the meaning of this piece of Standardese about shared_ptr's use_count()?

While trying to wrap my head around the problem shown in this question I found myself stuck on the following sentence from [util.smartptr.shared]/4:



[...] Changes in use_count() do not reflect modifications that can introduce data races.



I don't understand how I should read that, and what conclusions shall I draw. Here are a few interpretations:



  • Invoking use_count() does not introduce data races (but this should be guaranteed by the const-ness of that function alone, together with the corresponding library-wide guarantees)

  • The value returned by use_count() is not influenced by ("does not reflect"?) the outcome of operations that require atomicity or synchronization (but what are these relevant operations?)

  • use_count() is executed atomically, but without preventing reordering by the CPU or the compiler (i.e. without sequential consistency, but then why not mentioning the particular model?)


To me, none of the above seems to follow from that sentence, and I am at loss trying to interpret it.


Aucun commentaire:

Enregistrer un commentaire