aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkMutex_win.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-06-09 14:18:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-09 14:18:03 -0700
commitb83f6c3cbdabc14d8290b00d9f38ba59bf6719a1 (patch)
treea27fbddc35397dc0f32549e2af8a9c6d13e9c641 /src/ports/SkMutex_win.h
parent919ed4c73633e92bfc6694161360c5c3f45728e8 (diff)
Add assertHeld() to SkMutex.
BUG=skia: R=bungeman@google.com, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/313823004
Diffstat (limited to 'src/ports/SkMutex_win.h')
-rw-r--r--src/ports/SkMutex_win.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ports/SkMutex_win.h b/src/ports/SkMutex_win.h
index f4b8234e85..d12fd033f3 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;