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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/atomic_sequence_num.h" | 6 #include "base/atomic_sequence_num.h" |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/aligned_memory.h" | 8 #include "base/memory/aligned_memory.h" |
9 #include "base/threading/simple_thread.h" | 9 #include "base/threading/simple_thread.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 int some_int_; | 39 int some_int_; |
40 }; | 40 }; |
41 | 41 |
42 int SlowConstructor::constructed = 0; | 42 int SlowConstructor::constructed = 0; |
43 | 43 |
44 class SlowDelegate : public base::DelegateSimpleThread::Delegate { | 44 class SlowDelegate : public base::DelegateSimpleThread::Delegate { |
45 public: | 45 public: |
46 explicit SlowDelegate(base::LazyInstance<SlowConstructor>* lazy) | 46 explicit SlowDelegate(base::LazyInstance<SlowConstructor>* lazy) |
47 : lazy_(lazy) {} | 47 : lazy_(lazy) {} |
48 | 48 |
49 virtual void Run() OVERRIDE { | 49 virtual void Run() override { |
50 EXPECT_EQ(12, lazy_->Get().some_int()); | 50 EXPECT_EQ(12, lazy_->Get().some_int()); |
51 EXPECT_EQ(12, lazy_->Pointer()->some_int()); | 51 EXPECT_EQ(12, lazy_->Pointer()->some_int()); |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 base::LazyInstance<SlowConstructor>* lazy_; | 55 base::LazyInstance<SlowConstructor>* lazy_; |
56 }; | 56 }; |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // requirements. By ordering this way, the linker will need to do some work to | 163 // requirements. By ordering this way, the linker will need to do some work to |
164 // ensure proper alignment of the static data. | 164 // ensure proper alignment of the static data. |
165 static LazyInstance<AlignedData<4> > align4 = LAZY_INSTANCE_INITIALIZER; | 165 static LazyInstance<AlignedData<4> > align4 = LAZY_INSTANCE_INITIALIZER; |
166 static LazyInstance<AlignedData<32> > align32 = LAZY_INSTANCE_INITIALIZER; | 166 static LazyInstance<AlignedData<32> > align32 = LAZY_INSTANCE_INITIALIZER; |
167 static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER; | 167 static LazyInstance<AlignedData<4096> > align4096 = LAZY_INSTANCE_INITIALIZER; |
168 | 168 |
169 EXPECT_ALIGNED(align4.Pointer(), 4); | 169 EXPECT_ALIGNED(align4.Pointer(), 4); |
170 EXPECT_ALIGNED(align32.Pointer(), 32); | 170 EXPECT_ALIGNED(align32.Pointer(), 32); |
171 EXPECT_ALIGNED(align4096.Pointer(), 4096); | 171 EXPECT_ALIGNED(align4096.Pointer(), 4096); |
172 } | 172 } |
OLD | NEW |