| 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 | |
| 29 #include <memory> | 17 #include <memory> |
| 30 #endif // SK_DEBUG | 18 #endif // SK_DEBUG |
| 31 | 19 |
| 32 // There are two shared lock implementations one debug the other is high perform
ance. They implement | 20 // There are two shared lock implementations one debug the other is high perform
ance. They implement |
| 33 // an interface similar to pthread's rwlocks. | 21 // an interface similar to pthread's rwlocks. |
| 34 // This is a shared lock implementation similar to pthreads rwlocks. The high pe
rformance | 22 // This is a shared lock implementation similar to pthreads rwlocks. The high pe
rformance |
| 35 // implementation is cribbed from Preshing's article: | 23 // implementation is cribbed from Preshing's article: |
| 36 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ | 24 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ |
| 37 // | 25 // |
| 38 // This lock does not obey strict queue ordering. It will always alternate betwe
en readers and | 26 // 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... |
| 85 public: | 73 public: |
| 86 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha
red(); } | 74 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha
red(); } |
| 87 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } | 75 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } |
| 88 private: | 76 private: |
| 89 SkSharedMutex& fLock; | 77 SkSharedMutex& fLock; |
| 90 }; | 78 }; |
| 91 | 79 |
| 92 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare
d) | 80 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare
d) |
| 93 | 81 |
| 94 #endif // SkSharedLock_DEFINED | 82 #endif // SkSharedLock_DEFINED |
| OLD | NEW |