OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_THREADING_THREAD_LOCAL_STORAGE_H_ | 5 #ifndef BASE_THREADING_THREAD_LOCAL_STORAGE_H_ |
6 #define BASE_THREADING_THREAD_LOCAL_STORAGE_H_ | 6 #define BASE_THREADING_THREAD_LOCAL_STORAGE_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include <windows.h> | 13 #include <windows.h> |
14 #elif defined(OS_POSIX) | 14 #elif defined(OS_POSIX) |
15 #include <pthread.h> | 15 #include <pthread.h> |
16 #endif | 16 #endif |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 | 19 |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 // WARNING: You should *NOT* be using this class directly. | 22 // WARNING: You should *NOT* be using this class directly. |
23 // PlatformThreadLocalStorage is low-level abstraction to the OS's TLS | 23 // PlatformThreadLocalStorage is low-level abstraction to the OS's TLS |
24 // interface, you should instead be using ThreadLocalStorage::StaticSlot/Slot. | 24 // interface, you should instead be using ThreadLocalStorage::StaticSlot/Slot. |
25 class BASE_EXPORT PlatformThreadLocalStorage { | 25 class BASE_EXPORT PlatformThreadLocalStorage { |
26 public: | 26 public: |
27 | 27 |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 typedef unsigned long TLSKey; | 29 typedef unsigned long TLSKey; |
30 enum { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES }; | 30 enum : unsigned { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES }; |
31 #elif defined(OS_POSIX) | 31 #elif defined(OS_POSIX) |
32 typedef pthread_key_t TLSKey; | 32 typedef pthread_key_t TLSKey; |
33 // The following is a "reserved key" which is used in our generic Chromium | 33 // The following is a "reserved key" which is used in our generic Chromium |
34 // ThreadLocalStorage implementation. We expect that an OS will not return | 34 // ThreadLocalStorage implementation. We expect that an OS will not return |
35 // such a key, but if it is returned (i.e., the OS tries to allocate it) we | 35 // such a key, but if it is returned (i.e., the OS tries to allocate it) we |
36 // will just request another key. | 36 // will just request another key. |
37 enum { TLS_KEY_OUT_OF_INDEXES = 0x7FFFFFFF }; | 37 enum { TLS_KEY_OUT_OF_INDEXES = 0x7FFFFFFF }; |
38 #endif | 38 #endif |
39 | 39 |
40 // The following methods need to be supported on each OS platform, so that | 40 // The following methods need to be supported on each OS platform, so that |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 DISALLOW_COPY_AND_ASSIGN(Slot); | 138 DISALLOW_COPY_AND_ASSIGN(Slot); |
139 }; | 139 }; |
140 | 140 |
141 private: | 141 private: |
142 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); | 142 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); |
143 }; | 143 }; |
144 | 144 |
145 } // namespace base | 145 } // namespace base |
146 | 146 |
147 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ | 147 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ |
OLD | NEW |