OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkThread_DEFINED | 8 #ifndef SkThread_DEFINED |
9 #define SkThread_DEFINED | 9 #define SkThread_DEFINED |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 int32_t prev; | 53 int32_t prev; |
54 do { | 54 do { |
55 prev = *addr; | 55 prev = *addr; |
56 if (0 == prev) { | 56 if (0 == prev) { |
57 break; | 57 break; |
58 } | 58 } |
59 } while (!sk_atomic_cas(addr, prev, prev+1)); | 59 } while (!sk_atomic_cas(addr, prev, prev+1)); |
60 return prev; | 60 return prev; |
61 } | 61 } |
62 | 62 |
| 63 // SK_BARRIERS_PLATFORM_H must provide implementations for the following declara
tions: |
| 64 |
| 65 /** Prevent the compiler from reordering across this barrier. */ |
| 66 static void sk_compiler_barrier(); |
| 67 |
| 68 /** Read T*, with at least an acquire barrier. |
| 69 * |
| 70 * Only needs to be implemented for T which can be atomically read. |
| 71 */ |
| 72 template <typename T> T sk_acquire_load(T*); |
| 73 |
| 74 /** Write T*, with at least a release barrier. |
| 75 * |
| 76 * Only needs to be implemented for T which can be atomically written. |
| 77 */ |
| 78 template <typename T> void sk_release_store(T*, T); |
| 79 |
| 80 #include SK_BARRIERS_PLATFORM_H |
| 81 |
63 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. | 82 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. |
64 | 83 |
65 class SkBaseMutex { | 84 class SkBaseMutex { |
66 public: | 85 public: |
67 void acquire(); | 86 void acquire(); |
68 void release(); | 87 void release(); |
69 }; | 88 }; |
70 | 89 |
71 class SkMutex : SkBaseMutex { | 90 class SkMutex : SkBaseMutex { |
72 public: | 91 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 fMutex = NULL; | 127 fMutex = NULL; |
109 } | 128 } |
110 } | 129 } |
111 | 130 |
112 private: | 131 private: |
113 SkBaseMutex* fMutex; | 132 SkBaseMutex* fMutex; |
114 }; | 133 }; |
115 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) | 134 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
116 | 135 |
117 #endif | 136 #endif |
OLD | NEW |