| 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 #include "../private/SkSemaphore.h" | 11 #include "../private/SkSemaphore.h" |
| 12 #include "../private/SkThreadID.h" | 12 #include "../private/SkThreadID.h" |
| 13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
| 14 | 14 |
| 15 // TODO: no need for this anymore. | |
| 16 #define SK_DECLARE_STATIC_MUTEX(name) static SkMutex name; | |
| 17 | |
| 18 class SkMutex { | 15 class SkMutex { |
| 19 public: | 16 public: |
| 20 constexpr SkMutex() = default; | 17 constexpr SkMutex() = default; |
| 21 | 18 |
| 22 SkMutex(const SkMutex&) = delete; | 19 SkMutex(const SkMutex&) = delete; |
| 23 SkMutex& operator=(const SkMutex&) = delete; | 20 SkMutex& operator=(const SkMutex&) = delete; |
| 24 | 21 |
| 25 void acquire() { | 22 void acquire() { |
| 26 fSemaphore.wait(); | 23 fSemaphore.wait(); |
| 27 SkDEBUGCODE(fOwner = SkGetThreadID();) | 24 SkDEBUGCODE(fOwner = SkGetThreadID();) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 Lock &fLock; | 89 Lock &fLock; |
| 93 }; | 90 }; |
| 94 | 91 |
| 95 typedef SkAutoTAcquire<SkMutex> SkAutoMutexAcquire; | 92 typedef SkAutoTAcquire<SkMutex> SkAutoMutexAcquire; |
| 96 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) | 93 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
| 97 | 94 |
| 98 typedef SkAutoTExclusive<SkMutex> SkAutoMutexExclusive; | 95 typedef SkAutoTExclusive<SkMutex> SkAutoMutexExclusive; |
| 99 #define SkAutoMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexExclusive) | 96 #define SkAutoMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexExclusive) |
| 100 | 97 |
| 101 #endif//SkMutex_DEFINED | 98 #endif//SkMutex_DEFINED |
| OLD | NEW |