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.


Paolo Carlini wrote:
Robert Zeh wrote:

As a user who reads the mailing list and has experience with
multi-threaded applications,
my plea is for the first version of libstdc++'s tr1::shared_ptr to
use a mutex.

FWIW my opinion (again, I'm not a MT expert, even less a lock-free expert) I agree completely with you. Unfortunately, as Peter and Alexander are teaching us, even in that case, there are quite a few subtle issues...

Robert's suggestion, if I understand correctly, is to use a mutex for all operations, including counting (what boost::shared_ptr currently does on non-Windows platforms). This is guaranteed to be safe, but may generate some bad publicity, as the recent c.l.c++.m thread has shown.


However, if __exchange_and_add is reviewed and found/changed to be fully-fenced, this will automatically take care of all memory visibility issues in shared_ptr as well.


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