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 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 8 \ | |
23 && defined(SK_CPU_ARM32) && defined(SK_ARM_HAS_NEON) | |
24 typedef float float32_t; | |
25 #endif | |
bungeman-skia
2016/06/09 19:55:33
Can we add libc++ to this
#include <ciso646>
#if
mtklein_C
2016/06/09 20:19:43
Yep, done.
| |
26 | |
17 #include <memory> | 27 #include <memory> |
18 #endif // SK_DEBUG | 28 #endif // SK_DEBUG |
19 | 29 |
20 // There are two shared lock implementations one debug the other is high perform ance. They implement | 30 // There are two shared lock implementations one debug the other is high perform ance. They implement |
21 // an interface similar to pthread's rwlocks. | 31 // an interface similar to pthread's rwlocks. |
22 // This is a shared lock implementation similar to pthreads rwlocks. The high pe rformance | 32 // This is a shared lock implementation similar to pthreads rwlocks. The high pe rformance |
23 // implementation is cribbed from Preshing's article: | 33 // implementation is cribbed from Preshing's article: |
24 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ | 34 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ |
25 // | 35 // |
26 // This lock does not obey strict queue ordering. It will always alternate betwe en readers and | 36 // 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: | 83 public: |
74 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha red(); } | 84 SkAutoSharedMutexShared(SkSharedMutex& lock) : fLock(lock) { lock.acquireSha red(); } |
75 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } | 85 ~SkAutoSharedMutexShared() { fLock.releaseShared(); } |
76 private: | 86 private: |
77 SkSharedMutex& fLock; | 87 SkSharedMutex& fLock; |
78 }; | 88 }; |
79 | 89 |
80 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare d) | 90 #define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShare d) |
81 | 91 |
82 #endif // SkSharedLock_DEFINED | 92 #endif // SkSharedLock_DEFINED |
OLD | NEW |