| 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/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 // A key representing one value stored in TLS. | 92 // A key representing one value stored in TLS. |
| 93 // Initialize like | 93 // Initialize like |
| 94 // ThreadLocalStorage::StaticSlot my_slot = TLS_INITIALIZER; | 94 // ThreadLocalStorage::StaticSlot my_slot = TLS_INITIALIZER; |
| 95 // If you're not using a static variable, use the convenience class | 95 // If you're not using a static variable, use the convenience class |
| 96 // ThreadLocalStorage::Slot (below) instead. | 96 // ThreadLocalStorage::Slot (below) instead. |
| 97 struct BASE_EXPORT StaticSlot { | 97 struct BASE_EXPORT StaticSlot { |
| 98 // Set up the TLS slot. Called by the constructor. | 98 // Set up the TLS slot. Called by the constructor. |
| 99 // 'destructor' is a pointer to a function to perform per-thread cleanup of | 99 // 'destructor' is a pointer to a function to perform per-thread cleanup of |
| 100 // this object. If set to NULL, no cleanup is done for this TLS slot. | 100 // this object. If set to NULL, no cleanup is done for this TLS slot. |
| 101 // Returns false on error. | 101 void Initialize(TLSDestructorFunc destructor); |
| 102 bool Initialize(TLSDestructorFunc destructor); | |
| 103 | 102 |
| 104 // Free a previously allocated TLS 'slot'. | 103 // Free a previously allocated TLS 'slot'. |
| 105 // If a destructor was set for this slot, removes | 104 // If a destructor was set for this slot, removes |
| 106 // the destructor so that remaining threads exiting | 105 // the destructor so that remaining threads exiting |
| 107 // will not free data. | 106 // will not free data. |
| 108 void Free(); | 107 void Free(); |
| 109 | 108 |
| 110 // Get the thread-local value stored in slot 'slot'. | 109 // Get the thread-local value stored in slot 'slot'. |
| 111 // Values are guaranteed to initially be zero. | 110 // Values are guaranteed to initially be zero. |
| 112 void* Get() const; | 111 void* Get() const; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 136 DISALLOW_COPY_AND_ASSIGN(Slot); | 135 DISALLOW_COPY_AND_ASSIGN(Slot); |
| 137 }; | 136 }; |
| 138 | 137 |
| 139 private: | 138 private: |
| 140 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); | 139 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 } // namespace base | 142 } // namespace base |
| 144 | 143 |
| 145 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ | 144 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ |
| OLD | NEW |