This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Fw: [patch] Make std::tr1::shared_ptr thread-safe.
- From: "Peter Dimov" <pdimov at mmltd dot net>
- To: "Alexander Terekhov" <alexander dot terekhov at gmail dot com>
- Cc: <libstdc++ at gcc dot gnu dot org>,"Jonathan Wakely" <cow at compsoc dot man dot ac dot uk>
- Date: Thu, 31 Mar 2005 22:09:21 +0300
- Subject: Re: Fw: [patch] Make std::tr1::shared_ptr thread-safe.
- References: <OF24DE43AB.98214558-ONC1256FD5.0044D61E-C1256FD5.0044BD18@de.ibm.com> <e52efbe105033105212ee0988a@mail.gmail.com>
Alexander Terekhov wrote:
"Peter Dimov" <pdimov@mmltd.net> on 03/30/2005 11:33:56 PM:
[...]
3. Making __exchange_and_add offer the following memory
synchronization guarantees:
- acquire memory semantics when the result is not zero;
- release memory semantics when the result is zero
release memory semantics when the result is not zero;
acquire memory semantics when the result is zero
Umm, of course.
And "result" means new value of count stored by __exchange_and_add(),
not return value (its old value). BTW, I had a typo in my previous
message when I wrote "result > 1".
[...]
void weak_release() throw() {
if (!self_count_.decrement(msync::acq, count::may_not_store_min))
In an expanded form:
- no memory synchronization when the result is not zero (old value > 1)
- acquire memory semantics when the old value is 1 (may skip the final store
of 0)
destruct();
}
void release() throw() {
if (!use_count_.decrement()) { // "full" release-acquire protocol
As above:
- release memory semantics when the result is not zero;
- acquire memory semantics when the result is zero
dispose();
if (!self_count_.decrement(msync::rel, count::may_not_store_min))
- release memory semantics when result is not zero (old value > 1)
- no-op when the old value is 1 (no memory synchronization, may skip the
final store of 0)
destruct();
}
}
Right?