aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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 /include
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 'include')
-rw-r--r--include/core/SkThread.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/core/SkThread.h b/include/core/SkThread.h
index 3038e2d954..4f7f326097 100644
--- a/include/core/SkThread.h
+++ b/include/core/SkThread.h
@@ -83,8 +83,9 @@ template <typename T> void sk_release_store(T*, T);
class SkBaseMutex {
public:
- void acquire();
- void release();
+ void acquire(); // Block until this thread owns the mutex.
+ void release(); // Assuming this thread owns the mutex, release it.
+ void assertHeld(); // If SK_DEBUG, assert this thread owns the mutex.
};
class SkMutex : SkBaseMutex {
@@ -128,6 +129,12 @@ public:
}
}
+ /** Assert that we're holding the mutex. */
+ void assertHeld() {
+ SkASSERT(fMutex);
+ fMutex->assertHeld();
+ }
+
private:
SkBaseMutex* fMutex;
};