OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 // The LazyInstance<Type, Traits> class manages a single instance of Type, | 5 // The LazyInstance<Type, Traits> class manages a single instance of Type, |
6 // which will be lazily created on the first time it's accessed. This class is | 6 // which will be lazily created on the first time it's accessed. This class is |
7 // useful for places you would normally use a function-level static, but you | 7 // useful for places you would normally use a function-level static, but you |
8 // need to have guaranteed thread-safety. The Type constructor will only ever | 8 // need to have guaranteed thread-safety. The Type constructor will only ever |
9 // be called once, even if two threads are racing to create the object. Get() | 9 // be called once, even if two threads are racing to create the object. Get() |
10 // and Pointer() will always return the same, completely initialized instance. | 10 // and Pointer() will always return the same, completely initialized instance. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 template <typename T, | 226 template <typename T, |
227 typename CreateTrait = DefaultCreateTrait<T>, | 227 typename CreateTrait = DefaultCreateTrait<T>, |
228 typename InitOnceTrait = ThreadSafeInitOnceTrait, | 228 typename InitOnceTrait = ThreadSafeInitOnceTrait, |
229 typename DestroyTrait = LeakyInstanceTrait<T> > | 229 typename DestroyTrait = LeakyInstanceTrait<T> > |
230 struct LazyDynamicInstance { | 230 struct LazyDynamicInstance { |
231 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, | 231 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, |
232 CreateTrait, InitOnceTrait, DestroyTrait> type; | 232 CreateTrait, InitOnceTrait, DestroyTrait> type; |
233 }; | 233 }; |
234 | 234 |
235 } } // namespace v8::base | 235 } // namespace base |
| 236 } // namespace v8 |
236 | 237 |
237 #endif // V8_BASE_LAZY_INSTANCE_H_ | 238 #endif // V8_BASE_LAZY_INSTANCE_H_ |
OLD | NEW |