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

Side by Side Diff: third_party/WebKit/Source/wtf/SpinLock.cpp

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "wtf/SpinLock.h" 6 #include "wtf/SpinLock.h"
7 7
8 #include "wtf/Atomics.h" 8 #include "wtf/Atomics.h"
9 #include "wtf/CPU.h" 9 #include "wtf/CPU.h"
10 #include "wtf/Compiler.h" 10 #include "wtf/Compiler.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #if OS(POSIX) 44 #if OS(POSIX)
45 #define YIELD_THREAD sched_yield() 45 #define YIELD_THREAD sched_yield()
46 #else 46 #else
47 #warning "Thread yield not supported on this OS." 47 #warning "Thread yield not supported on this OS."
48 #define YIELD_THREAD ((void)0) 48 #define YIELD_THREAD ((void)0)
49 #endif 49 #endif
50 #endif 50 #endif
51 51
52 namespace WTF { 52 namespace WTF {
53 53
54 void slowSpinLockLock(int volatile* lock) 54 void slowSpinLockLock(int volatile* lock) {
55 { 55 // The value of kYieldProcessorTries is cargo culted from TCMalloc, Windows
56 // The value of kYieldProcessorTries is cargo culted from TCMalloc, Windows 56 // critical section defaults, and various other recommendations.
57 // critical section defaults, and various other recommendations. 57 // TODO(jschuh): Further tuning may be warranted.
58 // TODO(jschuh): Further tuning may be warranted. 58 static const int kYieldProcessorTries = 1000;
59 static const int kYieldProcessorTries = 1000; 59 do {
60 do { 60 do {
61 do { 61 for (int count = 0; count < kYieldProcessorTries; ++count) {
62 for (int count = 0; count < kYieldProcessorTries; ++count) { 62 // Let the Processor know we're spinning.
63 // Let the Processor know we're spinning. 63 YIELD_PROCESSOR;
64 YIELD_PROCESSOR; 64 if (!*lock && LIKELY(!atomicTestAndSetToOne(lock)))
65 if (!*lock && LIKELY(!atomicTestAndSetToOne(lock))) 65 return;
66 return; 66 }
67 }
68 67
69 // Give the OS a chance to schedule something on this core. 68 // Give the OS a chance to schedule something on this core.
70 YIELD_THREAD; 69 YIELD_THREAD;
71 } while (*lock); 70 } while (*lock);
72 } while (UNLIKELY(atomicTestAndSetToOne(lock))); 71 } while (UNLIKELY(atomicTestAndSetToOne(lock)));
73 } 72 }
74 73
75 } // namespace WTF 74 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/SpinLock.h ('k') | third_party/WebKit/Source/wtf/StaticConstructors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698