Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: base/memory/singleton.h

Issue 188603002: Fix base::internal::Singleton to use acquire loads instead of nobarrier ones. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/memory/singleton.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/singleton.h
===================================================================
--- base/memory/singleton.h (revision 255285)
+++ base/memory/singleton.h (working copy)
@@ -233,7 +233,9 @@
base::ThreadRestrictions::AssertSingletonAllowed();
#endif
- base::subtle::AtomicWord value = base::subtle::NoBarrier_Load(&instance_);
+ // The load has acquire memory ordering as the thread which reads the
+ // instance_ pointer must acquire visibility over the singleton data.
+ base::subtle::AtomicWord value = base::subtle::Acquire_Load(&instance_);
if (value != 0 && value != base::internal::kBeingCreatedMarker) {
// See the corresponding HAPPENS_BEFORE below.
ANNOTATE_HAPPENS_AFTER(&instance_);
@@ -252,6 +254,7 @@
// synchronization between different threads calling get().
// See the corresponding HAPPENS_AFTER below and above.
ANNOTATE_HAPPENS_BEFORE(&instance_);
+ // Releases the visibility over instance_ to the readers.
base::subtle::Release_Store(
&instance_, reinterpret_cast<base::subtle::AtomicWord>(newval));
« no previous file with comments | « no previous file | base/memory/singleton.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698