MCPcopy Create free account
hub / github.com/apache/impala / CompareAndSwap

Method CompareAndSwap

be/src/common/atomic.h:104–106  ·  view source on GitHub ↗

Atomically compare 'old_val' to 'value_' and set 'value_' to 'new_val' and return true if they compared equal, otherwise return false (and do no updates), with "barrier" memory-ordering semantic. That is, atomically performs: if (value_ == old_val) { value_ = new_val; return true; } return false;

Source from the content-addressed store, hash-verified

102 /// }
103 /// return false;
104 ALWAYS_INLINE bool CompareAndSwap(T old_val, T new_val) {
105 return base::subtle::Barrier_CompareAndSwap(&value_, old_val, new_val) == old_val;
106 }
107
108 /// Store 'new_val' and return the previous value. Implies a Release memory barrier
109 /// (i.e. the same as Store()).

Callers 4

TestBasicFunction · 0.45
CASIncrementThreadFunction · 0.45
CASDecrementThreadFunction · 0.45
CompareAndSwapMethod · 0.45

Calls 1

Barrier_CompareAndSwapFunction · 0.85

Tested by 3

TestBasicFunction · 0.36
CASIncrementThreadFunction · 0.36
CASDecrementThreadFunction · 0.36