summaryrefslogtreecommitdiff
path: root/runtime/base/mutex.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/base/mutex.cc')
-rw-r--r--runtime/base/mutex.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index cbcd408b6d..70b6f7e295 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -83,18 +83,25 @@ static bool ComputeRelativeTimeSpec(timespec* result_ts, const timespec& lhs, co
}
#endif
-class ScopedAllMutexesLock {
+class ScopedAllMutexesLock FINAL {
public:
explicit ScopedAllMutexesLock(const BaseMutex* mutex) : mutex_(mutex) {
while (!gAllMutexData->all_mutexes_guard.CompareExchangeWeakAcquire(0, mutex)) {
NanoSleep(100);
}
}
+
~ScopedAllMutexesLock() {
+#if !defined(__clang__)
+ // TODO: remove this workaround target GCC/libc++/bionic bug "invalid failure memory model".
+ while (!gAllMutexData->all_mutexes_guard.CompareExchangeWeakSequentiallyConsistent(mutex_, 0)) {
+#else
while (!gAllMutexData->all_mutexes_guard.CompareExchangeWeakRelease(mutex_, 0)) {
+#endif
NanoSleep(100);
}
}
+
private:
const BaseMutex* const mutex_;
};