Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Side by Side Diff: base/threading/thread_local_storage.h

Issue 1726203002: Refactor thread_local.h's TLS Implementation to use ThreadLocalStorage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to d98ce9a Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/threading/thread_local_posix.cc ('k') | base/threading/thread_local_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 10 #include "base/macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #include <windows.h> 14 #include <windows.h>
15 #elif defined(OS_POSIX) 15 #elif defined(OS_POSIX)
16 #include <pthread.h> 16 #include <pthread.h>
17 #endif 17 #endif
18 18
19 namespace base { 19 namespace base {
20 20
21 namespace internal { 21 namespace internal {
22 22
23 // WARNING: You should *NOT* be using this class directly. 23 // WARNING: You should *NOT* use this class directly.
24 // PlatformThreadLocalStorage is low-level abstraction to the OS's TLS 24 // PlatformThreadLocalStorage is a low-level abstraction of the OS's TLS
25 // interface, you should instead be using ThreadLocalStorage::StaticSlot/Slot. 25 // interface. Instead, you should use one of the following:
26 // * ThreadLocalBoolean (from thread_local.h) for booleans.
27 // * ThreadLocalPointer (from thread_local.h) for pointers.
28 // * ThreadLocalStorage::StaticSlot/Slot for more direct control of the slot.
26 class BASE_EXPORT PlatformThreadLocalStorage { 29 class BASE_EXPORT PlatformThreadLocalStorage {
27 public: 30 public:
28 31
29 #if defined(OS_WIN) 32 #if defined(OS_WIN)
30 typedef unsigned long TLSKey; 33 typedef unsigned long TLSKey;
31 enum : unsigned { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES }; 34 enum : unsigned { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES };
32 #elif defined(OS_POSIX) 35 #elif defined(OS_POSIX)
33 typedef pthread_key_t TLSKey; 36 typedef pthread_key_t TLSKey;
34 // The following is a "reserved key" which is used in our generic Chromium 37 // The following is a "reserved key" which is used in our generic Chromium
35 // ThreadLocalStorage implementation. We expect that an OS will not return 38 // ThreadLocalStorage implementation. We expect that an OS will not return
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 DISALLOW_COPY_AND_ASSIGN(Slot); 148 DISALLOW_COPY_AND_ASSIGN(Slot);
146 }; 149 };
147 150
148 private: 151 private:
149 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); 152 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage);
150 }; 153 };
151 154
152 } // namespace base 155 } // namespace base
153 156
154 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ 157 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_
OLDNEW
« no previous file with comments | « base/threading/thread_local_posix.cc ('k') | base/threading/thread_local_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698