From b83f6c3cbdabc14d8290b00d9f38ba59bf6719a1 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 9 Jun 2014 14:18:02 -0700 Subject: 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 --- src/ports/SkMutex_win.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ports/SkMutex_win.h') 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; -- cgit v1.2.3