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