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.


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?



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