Fix a typo in CompareExchangeStrong()

Use compare_exchange_strong() instead of compare_exchange_weak(), which
can be spuriously fail on some platforms.

Thanks to Mark Roth to pointing this out!
pull/18451/head
Soheil Hassas Yeganeh 6 years ago
parent ba7da20f1d
commit e6cae04e5f
  1. 2
      src/core/lib/gprpp/atomic.h

@ -58,7 +58,7 @@ class Atomic {
bool CompareExchangeStrong(T* expected, T desired, MemoryOrder success, bool CompareExchangeStrong(T* expected, T desired, MemoryOrder success,
MemoryOrder failure) { MemoryOrder failure) {
return GPR_ATM_INC_CAS_THEN(storage_.compare_exchange_weak( return GPR_ATM_INC_CAS_THEN(storage_.compare_exchange_strong(
*expected, desired, static_cast<std::memory_order>(success), *expected, desired, static_cast<std::memory_order>(success),
static_cast<std::memory_order>(failure))); static_cast<std::memory_order>(failure)));
} }

Loading…
Cancel
Save