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 template <typename T> T sk_acquire_load(T*); |
| 70 |
| 71 /** Write T*, with at least a release barrier. */ |
| 72 template <typename T> void sk_release_store(T*, T); |
| 73 |
| 74 #include SK_BARRIERS_PLATFORM_H |
| 75 |
63 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. | 76 /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. |
64 | 77 |
65 class SkBaseMutex { | 78 class SkBaseMutex { |
66 public: | 79 public: |
67 void acquire(); | 80 void acquire(); |
68 void release(); | 81 void release(); |
69 }; | 82 }; |
70 | 83 |
71 class SkMutex : SkBaseMutex { | 84 class SkMutex : SkBaseMutex { |
72 public: | 85 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 fMutex = NULL; | 121 fMutex = NULL; |
109 } | 122 } |
110 } | 123 } |
111 | 124 |
112 private: | 125 private: |
113 SkBaseMutex* fMutex; | 126 SkBaseMutex* fMutex; |
114 }; | 127 }; |
115 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) | 128 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
116 | 129 |
117 #endif | 130 #endif |
OLD | NEW |