| 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 29 matching lines...) Expand all Loading... |
| 40 // } | 40 // } |
| 41 // | 41 // |
| 42 // // Return the current MyClass associated with the calling thread, can be | 42 // // Return the current MyClass associated with the calling thread, can be |
| 43 // // NULL if there isn't a MyClass associated. | 43 // // NULL if there isn't a MyClass associated. |
| 44 // MyClass* MyClass::current() { | 44 // MyClass* MyClass::current() { |
| 45 // return Singleton<ThreadLocalPointer<MyClass> >::get()->Get(); | 45 // return Singleton<ThreadLocalPointer<MyClass> >::get()->Get(); |
| 46 // } | 46 // } |
| 47 | 47 |
| 48 #ifndef BASE_THREADING_THREAD_LOCAL_H_ | 48 #ifndef BASE_THREADING_THREAD_LOCAL_H_ |
| 49 #define BASE_THREADING_THREAD_LOCAL_H_ | 49 #define BASE_THREADING_THREAD_LOCAL_H_ |
| 50 #pragma once | |
| 51 | 50 |
| 52 #include "base/base_export.h" | 51 #include "base/base_export.h" |
| 53 #include "base/basictypes.h" | 52 #include "base/basictypes.h" |
| 54 | 53 |
| 55 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
| 56 #include <pthread.h> | 55 #include <pthread.h> |
| 57 #endif | 56 #endif |
| 58 | 57 |
| 59 namespace base { | 58 namespace base { |
| 60 | 59 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 119 |
| 121 private: | 120 private: |
| 122 ThreadLocalPointer<void> tlp_; | 121 ThreadLocalPointer<void> tlp_; |
| 123 | 122 |
| 124 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean); | 123 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean); |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 } // namespace base | 126 } // namespace base |
| 128 | 127 |
| 129 #endif // BASE_THREADING_THREAD_LOCAL_H_ | 128 #endif // BASE_THREADING_THREAD_LOCAL_H_ |
| OLD | NEW |