Chromium Code Reviews| 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. |
| + */ |
| + |
|
mtklein_C
2015/07/09 16:46:22
This all seems fine, but no longer germane to this
herb_g
2015/07/09 18:21:15
Done.
|
| #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) |