Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1314)

Unified Diff: third_party/WebKit/Source/wtf/SpinLock.cpp

Issue 1463683002: Switch wtf/SpinLock to std::atomic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asan iwyu Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/SpinLock.cpp
diff --git a/third_party/WebKit/Source/wtf/SpinLock.cpp b/third_party/WebKit/Source/wtf/SpinLock.cpp
index 542f97be672d9daa58242adadf775ff4bf0491a8..c85203b72d297b79bfe409f5d3d06168e2844807 100644
--- a/third_party/WebKit/Source/wtf/SpinLock.cpp
+++ b/third_party/WebKit/Source/wtf/SpinLock.cpp
@@ -53,7 +53,7 @@
namespace WTF {
-void slowSpinLockLock(int volatile* lock)
+void SpinLock::lockSlow()
{
// The value of kYieldProcessorTries is cargo culted from TCMalloc, Windows
// critical section defaults, and various other recommendations.
@@ -64,14 +64,14 @@ void slowSpinLockLock(int volatile* lock)
for (int count = 0; count < kYieldProcessorTries; ++count) {
// Let the Processor know we're spinning.
YIELD_PROCESSOR;
- if (!*lock && LIKELY(!atomicTestAndSetToOne(lock)))
+ if (!m_lock.load(std::memory_order_relaxed) && LIKELY(!m_lock.exchange(true, std::memory_order_acq_rel)))
return;
}
// Give the OS a chance to schedule something on this core.
YIELD_THREAD;
- } while (*lock);
- } while (UNLIKELY(atomicTestAndSetToOne(lock)));
+ } while (m_lock.load(std::memory_order_relaxed));
+ } while (UNLIKELY(m_lock.exchange(true, std::memory_order_acq_rel)));
}
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698