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

Unified Diff: include/core/SkMutex.h

Issue 1230583008: Create a template AutoTAcquire, and specialize an SkMutex version. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMutex.h
diff --git a/include/core/SkMutex.h b/include/core/SkMutex.h
index ea7e81726b88c05828f35753c877b129eab2a15d..08b220c3968c9b62f97495db15c8cdf1661992dc 100644
--- a/include/core/SkMutex.h
+++ b/include/core/SkMutex.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
#ifndef SkMutex_DEFINED
#define SkMutex_DEFINED
@@ -10,21 +17,22 @@
#include "../ports/SkMutex_pthread.h"
#endif
-class SkAutoMutexAcquire : SkNoncopyable {
+template <typename Lock>
+class SkAutoTAcquire : SkNoncopyable {
public:
- explicit SkAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex) {
+ explicit SkAutoTAcquire(Lock& mutex) : fMutex(&mutex) {
SkASSERT(fMutex != NULL);
mutex.acquire();
}
- explicit SkAutoMutexAcquire(SkBaseMutex* mutex) : fMutex(mutex) {
+ explicit SkAutoTAcquire(Lock* mutex) : fMutex(mutex) {
if (mutex) {
mutex->acquire();
}
}
/** If the mutex has not been released, release it now. */
- ~SkAutoMutexAcquire() {
+ ~SkAutoTAcquire() {
if (fMutex) {
fMutex->release();
}
@@ -45,8 +53,11 @@ public:
}
private:
- SkBaseMutex* fMutex;
+ Lock* fMutex;
};
+
+typedef SkAutoTAcquire<SkBaseMutex> SkAutoMutexAcquire;
+
#define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698