| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "base/threading/thread_local_storage.h" | 5 #include "base/threading/thread_local_storage.h" |
| 6 | 6 |
| 7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "build/build_config.h" |
| 9 | 10 |
| 10 using base::internal::PlatformThreadLocalStorage; | 11 using base::internal::PlatformThreadLocalStorage; |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 // In order to make TLS destructors work, we need to keep around a function | 14 // In order to make TLS destructors work, we need to keep around a function |
| 14 // pointer to the destructor for each slot. We keep this array of pointers in a | 15 // pointer to the destructor for each slot. We keep this array of pointers in a |
| 15 // global (static) array. | 16 // global (static) array. |
| 16 // We use the single OS-level TLS slot (giving us one pointer per thread) to | 17 // We use the single OS-level TLS slot (giving us one pointer per thread) to |
| 17 // hold a pointer to a per-thread array (table) of slots that we allocate to | 18 // hold a pointer to a per-thread array (table) of slots that we allocate to |
| 18 // Chromium consumers. | 19 // Chromium consumers. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 PlatformThreadLocalStorage::GetTLSValue( | 243 PlatformThreadLocalStorage::GetTLSValue( |
| 243 base::subtle::NoBarrier_Load(&g_native_tls_key))); | 244 base::subtle::NoBarrier_Load(&g_native_tls_key))); |
| 244 if (!tls_data) | 245 if (!tls_data) |
| 245 tls_data = ConstructTlsVector(); | 246 tls_data = ConstructTlsVector(); |
| 246 DCHECK_GT(slot_, 0); | 247 DCHECK_GT(slot_, 0); |
| 247 DCHECK_LT(slot_, kThreadLocalStorageSize); | 248 DCHECK_LT(slot_, kThreadLocalStorageSize); |
| 248 tls_data[slot_] = value; | 249 tls_data[slot_] = value; |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace base | 252 } // namespace base |
| OLD | NEW |