diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 08:33:13 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 08:33:13 +0000 |
commit | b321afd723f86131aedf27a7d38a2b69c99375c6 (patch) | |
tree | ef9c670c842c5f1f3a6b7ac6e0e7287a740deb66 /base/singleton.h | |
parent | f4df93213ea5e482373dae917386ccebd9f5b430 (diff) | |
download | chromium_src-b321afd723f86131aedf27a7d38a2b69c99375c6.zip chromium_src-b321afd723f86131aedf27a7d38a2b69c99375c6.tar.gz chromium_src-b321afd723f86131aedf27a7d38a2b69c99375c6.tar.bz2 |
Even though AtExit should never be called while an object is being accessed, it is cleaner and a bit safer to doing an AtomicExchange, so instance_ is not kept as the pointer value while we're deleting it. This also moves an unsafe direct access to the AtomicWord to calling through the atomic API.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/singleton.h')
-rw-r--r-- | base/singleton.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/base/singleton.h b/base/singleton.h index d57841b..b7c03ec 100644 --- a/base/singleton.h +++ b/base/singleton.h @@ -187,9 +187,8 @@ class Singleton { static void OnExit() { // AtExit should only ever be register after the singleton instance was // created. We should only ever get here with a valid instance_ pointer. - // We skip the DCHECK because we don't want to pull in logging.h :/ - Traits::Delete(reinterpret_cast<Type*>(instance_)); - base::subtle::Release_Store(&instance_, 0); + Traits::Delete(reinterpret_cast<Type*>( + base::subtle::NoBarrier_AtomicExchange(&instance_, 0))); } static base::subtle::AtomicWord instance_; }; |