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 |
11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
12 #include "SkSemaphore.h" | 12 #include "SkSemaphore.h" |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 #ifdef SK_DEBUG | 15 #ifdef SK_DEBUG |
16 #include "SkMutex.h" | 16 #include "SkMutex.h" |
| 17 |
| 18 // On GCC 4.8, targeting ARMv7 with NEON, using libc++, we need to typedef f
loat float32_t, |
| 19 // (or include <arm_neon.h> which does that) before #including <memory> here
. |
| 20 // This makes no sense. I'm not very interested in understanding why... thi
s is an old, |
| 21 // bizarre platform configuration that we should just let die. |
| 22 #include <ciso646> // Include something innocuous to define _LIBCPP_VERISON
if it's libc++. |
| 23 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 8 \ |
| 24 && defined(SK_CPU_ARM32) && defined(SK_ARM_HAS_NEON) \ |
| 25 && defined(_LIBCPP_VERSION) |
| 26 typedef float float32_t; |
| 27 #endif |
| 28 |
17 #include <memory> | 29 #include <memory> |
18 #endif // SK_DEBUG | 30 #endif // SK_DEBUG |
19 | 31 |
20 // There are two shared lock implementations one debug the other is high perform
ance. They implement | 32 // There are two shared lock implementations one debug the other is high perform
ance. They implement |
21 // an interface similar to pthread's rwlocks. | 33 // an interface similar to pthread's rwlocks. |
22 // This is a shared lock implementation similar to pthreads rwlocks. The high pe
rformance | 34 // This is a shared lock implementation similar to pthreads rwlocks. The high pe
rformance |
23 // implementation is cribbed from Preshing's article: | 35 // implementation is cribbed from Preshing's article: |
24 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ | 36 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ |
25 // | 37 // |
26 // This lock does not obey strict queue ordering. It will always alternate betwe
en readers and | 38 // This lock does not obey strict queue ordering. It will always alternate betwe
en readers and |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 public: | 85 public: |
74 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha
red(); } | 86 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha
red(); } |
75 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } | 87 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } |
76 private: | 88 private: |
77 SkSharedMutex& fLock; | 89 SkSharedMutex& fLock; |
78 }; | 90 }; |
79 | 91 |
80 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare
d) | 92 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare
d) |
81 | 93 |
82 #endif // SkSharedLock_DEFINED | 94 #endif // SkSharedLock_DEFINED |
OLD | NEW |