OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // WARNING: Thread local storage is a bit tricky to get right. Please make | 5 // WARNING: Thread local storage is a bit tricky to get right. Please make |
6 // sure that this is really the proper solution for what you're trying to | 6 // sure that this is really the proper solution for what you're trying to |
7 // achieve. Don't prematurely optimize, most likely you can just use a Lock. | 7 // achieve. Don't prematurely optimize, most likely you can just use a Lock. |
8 // | 8 // |
9 // These classes implement a wrapper around the platform's TLS storage | 9 // These classes implement a wrapper around the platform's TLS storage |
10 // mechanism. On construction, they will allocate a TLS slot, and free the | 10 // mechanism. On construction, they will allocate a TLS slot, and free the |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 #if defined(OS_POSIX) | 58 #if defined(OS_POSIX) |
59 #include <pthread.h> | 59 #include <pthread.h> |
60 #endif | 60 #endif |
61 | 61 |
62 namespace base { | 62 namespace base { |
63 namespace internal { | 63 namespace internal { |
64 | 64 |
65 // Helper functions that abstract the cross-platform APIs. Do not use directly. | 65 // Helper functions that abstract the cross-platform APIs. Do not use directly. |
66 struct BASE_EXPORT ThreadLocalPlatform { | 66 struct BASE_EXPORT ThreadLocalPlatform { |
67 #if defined(OS_WIN) | 67 #if defined(OS_ANDROID) |
68 typedef unsigned long SlotType; | |
69 #elif defined(OS_ANDROID) | |
70 typedef ThreadLocalStorage::StaticSlot SlotType; | 68 typedef ThreadLocalStorage::StaticSlot SlotType; |
71 #elif defined(OS_POSIX) | 69 #elif defined(OS_POSIX) |
72 typedef pthread_key_t SlotType; | 70 typedef pthread_key_t SlotType; |
73 #endif | 71 #endif |
74 | 72 |
75 static void AllocateSlot(SlotType* slot); | 73 static void AllocateSlot(SlotType* slot); |
76 static void FreeSlot(SlotType slot); | 74 static void FreeSlot(SlotType slot); |
77 static void* GetValueFromSlot(SlotType slot); | 75 static void* GetValueFromSlot(SlotType slot); |
78 static void SetValueInSlot(SlotType slot, void* value); | 76 static void SetValueInSlot(SlotType slot, void* value); |
79 }; | 77 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 122 |
125 private: | 123 private: |
126 ThreadLocalPointer<void> tlp_; | 124 ThreadLocalPointer<void> tlp_; |
127 | 125 |
128 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean); | 126 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean); |
129 }; | 127 }; |
130 | 128 |
131 } // namespace base | 129 } // namespace base |
132 | 130 |
133 #endif // BASE_THREADING_THREAD_LOCAL_H_ | 131 #endif // BASE_THREADING_THREAD_LOCAL_H_ |
OLD | NEW |