Chromium Code Reviews| 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 |