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: Fw: [patch] Make std::tr1::shared_ptr thread-safe.


Just to clarify. Peter Dimov wrote:

: Apologies for repeating myself, but this is an important point: the empty 
: critical sections fix a different problem (memory visibility). The 
: compare_and_swap way is not a substitute for them. It eliminates the 
: non-empty critical section in add_ref_lock, nothing more. 

Right. As for memory visibility, the issue here is that shared_ptr's 
"control block" is mutable object. The msync protocol on "self count" 
must take care of inter-thread ordering with respect to modifications 
(of another "use count", I mean) and destruction of control block. 
If it doesn't, then empty critical sections at the right places (on 
the same lock) can be used to sorta compensate that.

regards,
alexander.


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