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

Side by Side Diff: include/private/SkSpinlock.h

Issue 1757993006: Make Cmake work with debug build (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkSpinlock_DEFINED 8 #ifndef SkSpinlock_DEFINED
9 #define SkSpinlock_DEFINED 9 #define SkSpinlock_DEFINED
10 10
11 #include "SkTypes.h"
11 #include <atomic> 12 #include <atomic>
12 13
13 class SkSpinlock { 14 class SkSpinlock {
14 public: 15 public:
15 void acquire() { 16 void acquire() {
16 // To act as a mutex, we need an acquire barrier when we acquire the loc k. 17 // To act as a mutex, we need an acquire barrier when we acquire the loc k.
17 if (fLocked.exchange(true, std::memory_order_acquire)) { 18 if (fLocked.exchange(true, std::memory_order_acquire)) {
18 // Lock was contended. Fall back to an out-of-line spin loop. 19 // Lock was contended. Fall back to an out-of-line spin loop.
19 this->contendedAcquire(); 20 this->contendedAcquire();
20 } 21 }
21 } 22 }
22 23
23 void release() { 24 void release() {
24 // To act as a mutex, we need a release barrier when we release the lock . 25 // To act as a mutex, we need a release barrier when we release the lock .
25 fLocked.store(false, std::memory_order_release); 26 fLocked.store(false, std::memory_order_release);
26 } 27 }
27 28
28 private: 29 private:
29 void contendedAcquire(); 30 SK_API void contendedAcquire();
30 31
31 std::atomic<bool> fLocked{false}; 32 std::atomic<bool> fLocked{false};
32 }; 33 };
33 34
34 #endif//SkSpinlock_DEFINED 35 #endif//SkSpinlock_DEFINED
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698