LazyInstance should be thread safe by default.

The only ways we use this class require it, as multiple isolates can race
to initialize data structures. This showed up as intermittant failures on
nosnap build bots.

R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/238973004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20794 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9da828a5
...@@ -66,8 +66,8 @@ ...@@ -66,8 +66,8 @@
// LAZY_INSTANCE_INITIALIZER; // LAZY_INSTANCE_INITIALIZER;
// //
// WARNINGS: // WARNINGS:
// - This implementation of LazyInstance is NOT THREAD-SAFE by default. See // - This implementation of LazyInstance IS THREAD-SAFE by default. See
// ThreadSafeInitOnceTrait declared below for that. // SingleThreadInitOnceTrait if you don't care about thread safety.
// - Lazy initialization comes with a cost. Make sure that you don't use it on // - 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 // critical path. Consider adding your initialization code to a function
// which is explicitly called once. // which is explicitly called once.
...@@ -227,7 +227,7 @@ struct LazyInstanceImpl { ...@@ -227,7 +227,7 @@ struct LazyInstanceImpl {
template <typename T, template <typename T,
typename CreateTrait = DefaultConstructTrait<T>, typename CreateTrait = DefaultConstructTrait<T>,
typename InitOnceTrait = SingleThreadInitOnceTrait, typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyStaticInstance { struct LazyStaticInstance {
typedef LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>, typedef LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>,
...@@ -237,7 +237,7 @@ struct LazyStaticInstance { ...@@ -237,7 +237,7 @@ struct LazyStaticInstance {
template <typename T, template <typename T,
typename CreateTrait = DefaultConstructTrait<T>, typename CreateTrait = DefaultConstructTrait<T>,
typename InitOnceTrait = SingleThreadInitOnceTrait, typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyInstance { struct LazyInstance {
// A LazyInstance is a LazyStaticInstance. // A LazyInstance is a LazyStaticInstance.
...@@ -248,7 +248,7 @@ struct LazyInstance { ...@@ -248,7 +248,7 @@ struct LazyInstance {
template <typename T, template <typename T,
typename CreateTrait = DefaultCreateTrait<T>, typename CreateTrait = DefaultCreateTrait<T>,
typename InitOnceTrait = SingleThreadInitOnceTrait, typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyDynamicInstance { struct LazyDynamicInstance {
typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment