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

Unified Diff: src/ports/SkMutex_win.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkMutex_pthread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkMutex_win.h
diff --git a/src/ports/SkMutex_win.h b/src/ports/SkMutex_win.h
index f4b8234e85d70305ee28deb634158ae703a0734d..d12fd033f3d6d6a457d1b9022987572f8be9690f 100644
--- a/src/ports/SkMutex_win.h
+++ b/src/ports/SkMutex_win.h
@@ -36,25 +36,35 @@ class SkMutex {
public:
SkMutex() {
InitializeCriticalSection(&fStorage);
+ SkDEBUGCODE(fOwner = 0;)
}
~SkMutex() {
+ SkASSERT(0 == fOwner);
DeleteCriticalSection(&fStorage);
}
void acquire() {
EnterCriticalSection(&fStorage);
+ SkDEBUGCODE(fOwner = GetCurrentThreadId();)
}
void release() {
+ this->assertHeld();
+ SkDEBUGCODE(fOwner = 0;)
LeaveCriticalSection(&fStorage);
}
+ void assertHeld() {
+ SkASSERT(GetCurrentThreadId() == fOwner);
+ }
+
private:
SkMutex(const SkMutex&);
SkMutex& operator=(const SkMutex&);
CRITICAL_SECTION fStorage;
+ SkDEBUGCODE(DWORD fOwner;)
};
typedef SkMutex SkBaseMutex;
« no previous file with comments | « src/ports/SkMutex_pthread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698