diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 14:27:51 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 14:27:51 +0000 |
commit | 7c9f763d8b5867b227ab245ebd584f4a5eb6d3f0 (patch) | |
tree | b9e08da66632a79f881d6e82d97019bb338e79cd /base | |
parent | aa00b23b5a77dd7580f26a9b4ad780532935d653 (diff) | |
download | chromium_src-7c9f763d8b5867b227ab245ebd584f4a5eb6d3f0.zip chromium_src-7c9f763d8b5867b227ab245ebd584f4a5eb6d3f0.tar.gz chromium_src-7c9f763d8b5867b227ab245ebd584f4a5eb6d3f0.tar.bz2 |
Make Singleton::OnExit explicity not-threadsafe
This should help track down Singleton mis-usage, e.g.
BUG=61753
TEST=trybots
Review URL: http://codereview.chromium.org/4430003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/singleton.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/base/singleton.h b/base/singleton.h index 3fe16ce..564b686 100644 --- a/base/singleton.h +++ b/base/singleton.h @@ -239,12 +239,14 @@ class Singleton { private: // Adapter function for use with AtExit(). This should be called single - // threaded, but we might as well take the precautions anyway. + // threaded, so don't use atomic operations. + // Calling OnExit while singleton is in use by other threads is a mistake. static void OnExit(void* unused) { // AtExit should only ever be register after the singleton instance was // created. We should only ever get here with a valid instance_ pointer. - Traits::Delete(reinterpret_cast<Type*>( - base::subtle::NoBarrier_AtomicExchange(&instance_, 0))); + Traits::Delete( + reinterpret_cast<Type*>(base::subtle::NoBarrier_Load(&instance_))); + instance_ = 0; } static base::subtle::AtomicWord instance_; }; |