diff options
author | 2018-01-03 11:47:54 +0000 | |
---|---|---|
committer | 2018-01-03 12:45:40 +0000 | |
commit | 4557b3858a66aa20e42bce937e1f0620aad880a2 (patch) | |
tree | 8f34d8f014b11f17c6351bb955fcc74c940b8d16 /runtime/base/mutex-inl.h | |
parent | 90f20973356900e340998e8e2b34230e5c4c8fb0 (diff) |
ART: Rename Atomic::CompareExchange methods
Renames Atomic::CompareExchange methods to Atomic::CompareAndSet
equivalents. These methods return a boolean and do not get the witness
value. This makes space for Atomic::CompareAndExchange methods in a
later commit that will return a boolean and get the witness value.
This is pre-work for VarHandle accessors which require both forms.
Bug: 65872996
Test: art/test.py --host -j32
Change-Id: I9c691250e5556cbfde7811381b06d2920247f1a1
Diffstat (limited to 'runtime/base/mutex-inl.h')
-rw-r--r-- | runtime/base/mutex-inl.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index 587b092ab7..01adbf17e2 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -164,7 +164,7 @@ inline void ReaderWriterMutex::SharedLock(Thread* self) { int32_t cur_state = state_.LoadRelaxed(); if (LIKELY(cur_state >= 0)) { // Add as an extra reader. - done = state_.CompareExchangeWeakAcquire(cur_state, cur_state + 1); + done = state_.CompareAndSetWeakAcquire(cur_state, cur_state + 1); } else { HandleSharedLockContention(self, cur_state); } @@ -188,10 +188,10 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) { int32_t cur_state = state_.LoadRelaxed(); if (LIKELY(cur_state > 0)) { // Reduce state by 1 and impose lock release load/store ordering. - // Note, the relaxed loads below musn't reorder before the CompareExchange. + // Note, the relaxed loads below musn't reorder before the CompareAndSet. // TODO: the ordering here is non-trivial as state is split across 3 fields, fix by placing // a status bit into the state on contention. - done = state_.CompareExchangeWeakSequentiallyConsistent(cur_state, cur_state - 1); + done = state_.CompareAndSetWeakSequentiallyConsistent(cur_state, cur_state - 1); if (done && (cur_state - 1) == 0) { // Weak CAS may fail spuriously. if (num_pending_writers_.LoadRelaxed() > 0 || num_pending_readers_.LoadRelaxed() > 0) { |