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

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: sync again 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..5971c50a566e0554c3902084009c3884c0fe4ea1 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::SlowLock()
{
// 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() && LIKELY(!m_lock.exchange(true)))
Alexander Potapenko 2015/12/04 12:17:34 load() can be made memory_order_relaxed, and excha
jschuh 2015/12/04 20:45:13 Done.
return;
}
// Give the OS a chance to schedule something on this core.
YIELD_THREAD;
- } while (*lock);
- } while (UNLIKELY(atomicTestAndSetToOne(lock)));
+ } while (m_lock.exchange(true));
Alexander Potapenko 2015/12/04 12:17:34 memory_order_acq_rel
jschuh 2015/12/04 20:45:13 Actually, this was a mistake on my part and should
+ } while (UNLIKELY(m_lock.exchange(true)));
Alexander Potapenko 2015/12/04 12:17:34 ditto.
jschuh 2015/12/04 20:45:13 Done.
}
} // namespace WTF
« third_party/WebKit/Source/wtf/SpinLock.h ('K') | « third_party/WebKit/Source/wtf/SpinLock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698