| 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 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/threading/simple_thread.h" | 6 #include "base/threading/simple_thread.h" |
| 7 #include "base/threading/thread_local.h" | 7 #include "base/threading/thread_local.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class SetThreadLocal : public ThreadLocalTesterBase { | 30 class SetThreadLocal : public ThreadLocalTesterBase { |
| 31 public: | 31 public: |
| 32 SetThreadLocal(TLPType* tlp, base::WaitableEvent* done) | 32 SetThreadLocal(TLPType* tlp, base::WaitableEvent* done) |
| 33 : ThreadLocalTesterBase(tlp, done), | 33 : ThreadLocalTesterBase(tlp, done), |
| 34 val_(NULL) { | 34 val_(NULL) { |
| 35 } | 35 } |
| 36 virtual ~SetThreadLocal() {} | 36 virtual ~SetThreadLocal() {} |
| 37 | 37 |
| 38 void set_value(ThreadLocalTesterBase* val) { val_ = val; } | 38 void set_value(ThreadLocalTesterBase* val) { val_ = val; } |
| 39 | 39 |
| 40 virtual void Run() OVERRIDE { | 40 virtual void Run() override { |
| 41 DCHECK(!done_->IsSignaled()); | 41 DCHECK(!done_->IsSignaled()); |
| 42 tlp_->Set(val_); | 42 tlp_->Set(val_); |
| 43 done_->Signal(); | 43 done_->Signal(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 ThreadLocalTesterBase* val_; | 47 ThreadLocalTesterBase* val_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class GetThreadLocal : public ThreadLocalTesterBase { | 50 class GetThreadLocal : public ThreadLocalTesterBase { |
| 51 public: | 51 public: |
| 52 GetThreadLocal(TLPType* tlp, base::WaitableEvent* done) | 52 GetThreadLocal(TLPType* tlp, base::WaitableEvent* done) |
| 53 : ThreadLocalTesterBase(tlp, done), | 53 : ThreadLocalTesterBase(tlp, done), |
| 54 ptr_(NULL) { | 54 ptr_(NULL) { |
| 55 } | 55 } |
| 56 virtual ~GetThreadLocal() {} | 56 virtual ~GetThreadLocal() {} |
| 57 | 57 |
| 58 void set_ptr(ThreadLocalTesterBase** ptr) { ptr_ = ptr; } | 58 void set_ptr(ThreadLocalTesterBase** ptr) { ptr_ = ptr; } |
| 59 | 59 |
| 60 virtual void Run() OVERRIDE { | 60 virtual void Run() override { |
| 61 DCHECK(!done_->IsSignaled()); | 61 DCHECK(!done_->IsSignaled()); |
| 62 *ptr_ = tlp_->Get(); | 62 *ptr_ = tlp_->Get(); |
| 63 done_->Signal(); | 63 done_->Signal(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 ThreadLocalTesterBase** ptr_; | 67 ThreadLocalTesterBase** ptr_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Our slot should have been freed, we're all reset. | 162 // Our slot should have been freed, we're all reset. |
| 163 { | 163 { |
| 164 base::ThreadLocalBoolean tlb; | 164 base::ThreadLocalBoolean tlb; |
| 165 EXPECT_FALSE(tlb.Get()); | 165 EXPECT_FALSE(tlb.Get()); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace base | 169 } // namespace base |
| OLD | NEW |