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 "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 }; | 85 }; |
86 | 86 |
87 struct TlsVectorEntry { | 87 struct TlsVectorEntry { |
88 void* data; | 88 void* data; |
89 uint32_t version; | 89 uint32_t version; |
90 }; | 90 }; |
91 | 91 |
92 // This lock isn't needed until after we've constructed the per-thread TLS | 92 // This lock isn't needed until after we've constructed the per-thread TLS |
93 // vector, so it's safe to use. | 93 // vector, so it's safe to use. |
94 base::Lock* GetTLSMetadataLock() { | 94 base::Lock* GetTLSMetadataLock() { |
95 static auto lock = new base::Lock(); | 95 static auto* lock = new base::Lock(); |
96 return lock; | 96 return lock; |
97 } | 97 } |
98 TlsMetadata g_tls_metadata[kThreadLocalStorageSize]; | 98 TlsMetadata g_tls_metadata[kThreadLocalStorageSize]; |
99 size_t g_last_assigned_slot = 0; | 99 size_t g_last_assigned_slot = 0; |
100 | 100 |
101 // The maximum number of times to try to clear slots by calling destructors. | 101 // The maximum number of times to try to clear slots by calling destructors. |
102 // Use pthread naming convention for clarity. | 102 // Use pthread naming convention for clarity. |
103 constexpr int kMaxDestructorIterations = kThreadLocalStorageSize; | 103 constexpr int kMaxDestructorIterations = kThreadLocalStorageSize; |
104 | 104 |
105 // This function is called to initialize our entire Chromium TLS system. | 105 // This function is called to initialize our entire Chromium TLS system. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 338 |
339 void* ThreadLocalStorage::Slot::Get() const { | 339 void* ThreadLocalStorage::Slot::Get() const { |
340 return tls_slot_.Get(); | 340 return tls_slot_.Get(); |
341 } | 341 } |
342 | 342 |
343 void ThreadLocalStorage::Slot::Set(void* value) { | 343 void ThreadLocalStorage::Slot::Set(void* value) { |
344 tls_slot_.Set(value); | 344 tls_slot_.Set(value); |
345 } | 345 } |
346 | 346 |
347 } // namespace base | 347 } // namespace base |
OLD | NEW |