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

Side by Side Diff: include/core/SkThread.h

Issue 313823004: Add assertHeld() to SkMutex. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years, 6 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 | src/core/SkPaint.cpp » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkThread_DEFINED 8 #ifndef SkThread_DEFINED
9 #define SkThread_DEFINED 9 #define SkThread_DEFINED
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * Only needs to be implemented for T which can be atomically written. 76 * Only needs to be implemented for T which can be atomically written.
77 */ 77 */
78 template <typename T> void sk_release_store(T*, T); 78 template <typename T> void sk_release_store(T*, T);
79 79
80 #include SK_BARRIERS_PLATFORM_H 80 #include SK_BARRIERS_PLATFORM_H
81 81
82 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. 82 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations.
83 83
84 class SkBaseMutex { 84 class SkBaseMutex {
85 public: 85 public:
86 void acquire(); 86 void acquire(); // Block until this thread owns the mutex.
87 void release(); 87 void release(); // Assuming this thread owns the mutex, release it.
88 void assertHeld(); // If SK_DEBUG, assert this thread owns the mutex.
88 }; 89 };
89 90
90 class SkMutex : SkBaseMutex { 91 class SkMutex : SkBaseMutex {
91 public: 92 public:
92 SkMutex(); 93 SkMutex();
93 ~SkMutex(); 94 ~SkMutex();
94 }; 95 };
95 96
96 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name = ... 97 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name = ...
97 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name = ... 98 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name = ...
(...skipping 23 matching lines...) Expand all
121 } 122 }
122 123
123 /** If the mutex has not been released, release it now. */ 124 /** If the mutex has not been released, release it now. */
124 void release() { 125 void release() {
125 if (fMutex) { 126 if (fMutex) {
126 fMutex->release(); 127 fMutex->release();
127 fMutex = NULL; 128 fMutex = NULL;
128 } 129 }
129 } 130 }
130 131
132 /** Assert that we're holding the mutex. */
133 void assertHeld() {
134 SkASSERT(fMutex);
135 fMutex->assertHeld();
136 }
137
131 private: 138 private:
132 SkBaseMutex* fMutex; 139 SkBaseMutex* fMutex;
133 }; 140 };
134 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) 141 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire)
135 142
136 #endif 143 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698