summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 14:27:51 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 14:27:51 +0000
commit7c9f763d8b5867b227ab245ebd584f4a5eb6d3f0 (patch)
treeb9e08da66632a79f881d6e82d97019bb338e79cd /base
parentaa00b23b5a77dd7580f26a9b4ad780532935d653 (diff)
downloadchromium_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.h8
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_;
};