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 SkSharedLock_DEFINED | 8 #ifndef SkSharedLock_DEFINED |
9 #define SkSharedLock_DEFINED | 9 #define SkSharedLock_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 class SkSharedMutex { | 21 class SkSharedMutex { |
22 public: | 22 public: |
23 SkSharedMutex(); | 23 SkSharedMutex(); |
24 ~SkSharedMutex(); | 24 ~SkSharedMutex(); |
25 // Acquire lock for exclusive use. | 25 // Acquire lock for exclusive use. |
26 void acquire(); | 26 void acquire(); |
27 | 27 |
28 // Release lock for exclusive use. | 28 // Release lock for exclusive use. |
29 void release(); | 29 void release(); |
30 | 30 |
| 31 // Fail if exclusive is not held. |
| 32 #ifdef SK_DEBUG |
| 33 void assertHeld() const; |
| 34 #else |
| 35 void assertHeld() const {} |
| 36 #endif |
| 37 |
31 // Acquire lock for shared use. | 38 // Acquire lock for shared use. |
32 void acquireShared(); | 39 void acquireShared(); |
33 | 40 |
34 // Release lock for shared use. | 41 // Release lock for shared use. |
35 void releaseShared(); | 42 void releaseShared(); |
36 | 43 |
| 44 // Fail if shared lock not held. |
| 45 #ifdef SK_DEBUG |
| 46 void assertHeldShared() const; |
| 47 #else |
| 48 void assertHeldShared() const {} |
| 49 #endif |
| 50 |
37 private: | 51 private: |
38 SkAtomic<int32_t> fQueueCounts; | 52 SkAtomic<int32_t> fQueueCounts; |
39 SkSemaphore fSharedQueue; | 53 SkSemaphore fSharedQueue; |
40 SkSemaphore fExclusiveQueue; | 54 SkSemaphore fExclusiveQueue; |
41 }; | 55 }; |
42 | 56 |
| 57 |
43 #endif // SkSharedLock_DEFINED | 58 #endif // SkSharedLock_DEFINED |
OLD | NEW |