| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkMutex_DEFINED | 8 #ifndef SkMutex_DEFINED |
| 9 #define SkMutex_DEFINED | 9 #define SkMutex_DEFINED |
| 10 | 10 |
| 11 // This file is not part of the public Skia API. | 11 // This file is not part of the public Skia API. |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 | 13 |
| 14 // IWYU pragma: begin_exports |
| 14 #if defined(SK_BUILD_FOR_WIN) | 15 #if defined(SK_BUILD_FOR_WIN) |
| 15 #include "../ports/SkMutex_win.h" | 16 #include "../ports/SkMutex_win.h" |
| 16 #else | 17 #else |
| 17 #include "../ports/SkMutex_pthread.h" | 18 #include "../ports/SkMutex_pthread.h" |
| 18 #endif | 19 #endif |
| 20 // IWYU pragma: end_exports |
| 19 | 21 |
| 20 template <typename Lock> | 22 template <typename Lock> |
| 21 class SkAutoTAcquire : SkNoncopyable { | 23 class SkAutoTAcquire : SkNoncopyable { |
| 22 public: | 24 public: |
| 23 explicit SkAutoTAcquire(Lock& mutex) : fMutex(&mutex) { | 25 explicit SkAutoTAcquire(Lock& mutex) : fMutex(&mutex) { |
| 24 SkASSERT(fMutex != NULL); | 26 SkASSERT(fMutex != NULL); |
| 25 mutex.acquire(); | 27 mutex.acquire(); |
| 26 } | 28 } |
| 27 | 29 |
| 28 explicit SkAutoTAcquire(Lock* mutex) : fMutex(mutex) { | 30 explicit SkAutoTAcquire(Lock* mutex) : fMutex(mutex) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 55 private: | 57 private: |
| 56 Lock* fMutex; | 58 Lock* fMutex; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 typedef SkAutoTAcquire<SkBaseMutex> SkAutoMutexAcquire; | 61 typedef SkAutoTAcquire<SkBaseMutex> SkAutoMutexAcquire; |
| 60 | 62 |
| 61 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) | 63 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
| 62 | 64 |
| 63 | 65 |
| 64 #endif//SkMutex_DEFINED | 66 #endif//SkMutex_DEFINED |
| OLD | NEW |