Chromium Code Reviews| Index: src/lazy-instance.h |
| diff --git a/src/lazy-instance.h b/src/lazy-instance.h |
| index fc03f4d126025070fb490073ff9984446d68af3c..86473fd63ae7c90c6c1952f3a31ed8d8df7d9496 100644 |
| --- a/src/lazy-instance.h |
| +++ b/src/lazy-instance.h |
| @@ -66,8 +66,8 @@ |
| // LAZY_INSTANCE_INITIALIZER; |
| // |
| // WARNINGS: |
| -// - This implementation of LazyInstance is NOT THREAD-SAFE by default. See |
| -// ThreadSafeInitOnceTrait declared below for that. |
| +// - This implementation of LazyInstance IS THREAD-SAFE by default. See |
| +// SingleThreadInitOnceTrait if you don't care about thread safety. |
| // - Lazy initialization comes with a cost. Make sure that you don't use it on |
| // critical path. Consider adding your initialization code to a function |
| // which is explicitly called once. |
| @@ -174,6 +174,8 @@ struct ThreadSafeInitOnceTrait { |
| // Initialization trait for users who don't care about thread-safety. |
| +// |
| +// Thank you for making this the default, Satan. |
|
Hannes Payer (out of office)
2014/04/16 07:56:56
Very entertaining, but we should probably not have
|
| struct SingleThreadInitOnceTrait { |
| template <typename Function, typename Storage> |
| static void Init(OnceType* once, Function function, Storage storage) { |
| @@ -227,7 +229,7 @@ struct LazyInstanceImpl { |
| template <typename T, |
| typename CreateTrait = DefaultConstructTrait<T>, |
| - typename InitOnceTrait = SingleThreadInitOnceTrait, |
| + typename InitOnceTrait = ThreadSafeInitOnceTrait, |
| typename DestroyTrait = LeakyInstanceTrait<T> > |
| struct LazyStaticInstance { |
| typedef LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>, |
| @@ -237,7 +239,7 @@ struct LazyStaticInstance { |
| template <typename T, |
| typename CreateTrait = DefaultConstructTrait<T>, |
| - typename InitOnceTrait = SingleThreadInitOnceTrait, |
| + typename InitOnceTrait = ThreadSafeInitOnceTrait, |
| typename DestroyTrait = LeakyInstanceTrait<T> > |
| struct LazyInstance { |
| // A LazyInstance is a LazyStaticInstance. |
| @@ -248,7 +250,7 @@ struct LazyInstance { |
| template <typename T, |
| typename CreateTrait = DefaultCreateTrait<T>, |
| - typename InitOnceTrait = SingleThreadInitOnceTrait, |
| + typename InitOnceTrait = ThreadSafeInitOnceTrait, |
| typename DestroyTrait = LeakyInstanceTrait<T> > |
| struct LazyDynamicInstance { |
| typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, |