| 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/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 static ThreadLocalStorage::StaticSlot tls_slot = TLS_INITIALIZER; | 29 static ThreadLocalStorage::StaticSlot tls_slot = TLS_INITIALIZER; |
| 30 | 30 |
| 31 class ThreadLocalStorageRunner : public DelegateSimpleThread::Delegate { | 31 class ThreadLocalStorageRunner : public DelegateSimpleThread::Delegate { |
| 32 public: | 32 public: |
| 33 explicit ThreadLocalStorageRunner(int* tls_value_ptr) | 33 explicit ThreadLocalStorageRunner(int* tls_value_ptr) |
| 34 : tls_value_ptr_(tls_value_ptr) {} | 34 : tls_value_ptr_(tls_value_ptr) {} |
| 35 | 35 |
| 36 virtual ~ThreadLocalStorageRunner() {} | 36 virtual ~ThreadLocalStorageRunner() {} |
| 37 | 37 |
| 38 virtual void Run() OVERRIDE { | 38 void Run() override { |
| 39 *tls_value_ptr_ = kInitialTlsValue; | 39 *tls_value_ptr_ = kInitialTlsValue; |
| 40 tls_slot.Set(tls_value_ptr_); | 40 tls_slot.Set(tls_value_ptr_); |
| 41 | 41 |
| 42 int *ptr = static_cast<int*>(tls_slot.Get()); | 42 int *ptr = static_cast<int*>(tls_slot.Get()); |
| 43 EXPECT_EQ(ptr, tls_value_ptr_); | 43 EXPECT_EQ(ptr, tls_value_ptr_); |
| 44 EXPECT_EQ(*ptr, kInitialTlsValue); | 44 EXPECT_EQ(*ptr, kInitialTlsValue); |
| 45 *tls_value_ptr_ = 0; | 45 *tls_value_ptr_ = 0; |
| 46 | 46 |
| 47 ptr = static_cast<int*>(tls_slot.Get()); | 47 ptr = static_cast<int*>(tls_slot.Get()); |
| 48 EXPECT_EQ(ptr, tls_value_ptr_); | 48 EXPECT_EQ(ptr, tls_value_ptr_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 delete threads[index]; | 120 delete threads[index]; |
| 121 delete thread_delegates[index]; | 121 delete thread_delegates[index]; |
| 122 | 122 |
| 123 // Verify that the destructor was called and that we reset. | 123 // Verify that the destructor was called and that we reset. |
| 124 EXPECT_EQ(values[index], kFinalTlsValue); | 124 EXPECT_EQ(values[index], kFinalTlsValue); |
| 125 } | 125 } |
| 126 tls_slot.Free(); // Stop doing callbacks to cleanup threads. | 126 tls_slot.Free(); // Stop doing callbacks to cleanup threads. |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace base | 129 } // namespace base |
| OLD | NEW |