diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 20:41:47 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 20:41:47 +0000 |
commit | dcc6933f480397af42af5fa08d40475c13d266e8 (patch) | |
tree | ee6e4ca772e87f9ce27f60315895e7d9392d814e /base/lazy_instance.h | |
parent | 363dc7f1f2025475b418bfee73efe3030d9b1313 (diff) | |
download | chromium_src-dcc6933f480397af42af5fa08d40475c13d266e8.zip chromium_src-dcc6933f480397af42af5fa08d40475c13d266e8.tar.gz chromium_src-dcc6933f480397af42af5fa08d40475c13d266e8.tar.bz2 |
ThreadRestrictions: leak the thread local variable
LazyInstances are destroyed by the AtExitManager, but we have
threads that outlive the AtExitManager that could potentially
access this.
Review URL: http://codereview.chromium.org/3956003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/lazy_instance.h')
-rw-r--r-- | base/lazy_instance.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/base/lazy_instance.h b/base/lazy_instance.h index 52a5124..ebf1e73 100644 --- a/base/lazy_instance.h +++ b/base/lazy_instance.h @@ -55,6 +55,22 @@ struct DefaultLazyInstanceTraits { } }; +template <typename Type> +struct LeakyLazyInstanceTraits { + static Type* New(void* instance) { + return DefaultLazyInstanceTraits<Type>::New(instance); + } + // Rather than define an empty Delete function, we make Delete itself + // a null pointer. This allows us to completely sidestep registering + // this object with an AtExitManager, which allows you to use + // LeakyLazyInstanceTraits in contexts where you don't have an + // AtExitManager. + static void (*Delete)(void* instance); +}; + +template <typename Type> +void (*LeakyLazyInstanceTraits<Type>::Delete)(void* instance) = NULL; + // We pull out some of the functionality into a non-templated base, so that we // can implement the more complicated pieces out of line in the .cc file. class LazyInstanceHelper { |