summaryrefslogtreecommitdiffstats
path: root/base/lazy_instance.h
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 15:20:57 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 15:20:57 +0000
commit62ea451a03dbd33c293e53e6f6a777a23b87f18c (patch)
tree65a8ec768892287061ff6837ed87deda7761bc05 /base/lazy_instance.h
parentf660b6a9eab863ea371e990006324b45ede3c384 (diff)
downloadchromium_src-62ea451a03dbd33c293e53e6f6a777a23b87f18c.zip
chromium_src-62ea451a03dbd33c293e53e6f6a777a23b87f18c.tar.gz
chromium_src-62ea451a03dbd33c293e53e6f6a777a23b87f18c.tar.bz2
Just by implementing a destructor (even if it's not doing anything), MSVC will register a static initializer as to register the empty destructor. Pretty awesome. Verified that the c++ initializer is no longer in the __xc_a array.
Review URL: http://codereview.chromium.org/1812 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/lazy_instance.h')
-rw-r--r--base/lazy_instance.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index 33eefe8..0849503 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -64,7 +64,8 @@ class LazyInstanceHelper {
};
explicit LazyInstanceHelper(LinkerInitialized x) { /* state_ is 0 */ }
- ~LazyInstanceHelper() { }
+ // Declaring a destructor (even if it's empty) will cause MSVC to register a
+ // static initializer to register the empty destructor with atexit().
// Make sure that instance is created, creating or waiting for it to be
// created if neccessary. Constructs with |ctor| in the space provided by
@@ -81,7 +82,8 @@ template <typename Type, typename Traits = DefaultLazyInstanceTraits<Type> >
class LazyInstance : public LazyInstanceHelper {
public:
explicit LazyInstance(LinkerInitialized x) : LazyInstanceHelper(x) { }
- ~LazyInstance() { }
+ // Declaring a destructor (even if it's empty) will cause MSVC to register a
+ // static initializer to register the empty destructor with atexit().
Type& Get() {
return *Pointer();