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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <process.h> | 7 #include <process.h> |
8 #endif | 8 #endif |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 delete threads[index]; | 121 delete threads[index]; |
122 delete thread_delegates[index]; | 122 delete thread_delegates[index]; |
123 | 123 |
124 // Verify that the destructor was called and that we reset. | 124 // Verify that the destructor was called and that we reset. |
125 EXPECT_EQ(values[index], kFinalTlsValue); | 125 EXPECT_EQ(values[index], kFinalTlsValue); |
126 } | 126 } |
127 tls_slot.Free(); // Stop doing callbacks to cleanup threads. | 127 tls_slot.Free(); // Stop doing callbacks to cleanup threads. |
128 } | 128 } |
129 | 129 |
130 TEST(ThreadLocalStorageTest, TLSReclaim) { | 130 TEST(ThreadLocalStorageTest, TLSReclaim) { |
131 // Creates and destroys many TLS slots. | 131 // Creates and destroys many TLS slots and ensures they all zero-inited. |
132 for (int i = 0; i < 1000; ++i) { | 132 for (int i = 0; i < 1000; ++i) { |
133 ThreadLocalStorage::Slot slot(nullptr); | 133 ThreadLocalStorage::Slot slot(nullptr); |
| 134 EXPECT_EQ(nullptr, slot.Get()); |
| 135 slot.Set(reinterpret_cast<void*>(0xBAADF00D)); |
| 136 EXPECT_EQ(reinterpret_cast<void*>(0xBAADF00D), slot.Get()); |
134 } | 137 } |
135 } | 138 } |
136 | 139 |
137 } // namespace base | 140 } // namespace base |
OLD | NEW |