summaryrefslogtreecommitdiffstats
path: root/base/lazy_instance.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/lazy_instance.h')
-rw-r--r--base/lazy_instance.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index 1705b0f..d0cc109 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -37,6 +37,7 @@
#include "base/atomicops.h"
#include "base/basictypes.h"
+#include "base/dynamic_annotations.h"
namespace base {
@@ -96,6 +97,14 @@ class LazyInstance : public LazyInstanceHelper {
if (base::subtle::NoBarrier_Load(&state_) != STATE_CREATED)
EnsureInstance(instance, Traits::New, Traits::Delete);
+ // This annotation helps race detectors recognize correct lock-less
+ // synchronization between different threads calling Pointer().
+ // We suggest dynamic race detection tool that
+ // "ctor(instance)" in EnsureInstance(...) happens before
+ // "return instance" in Pointer().
+ // See the corresponding HAPPENS_BEFORE in EnsureInstance(...).
+ ANNOTATE_HAPPENS_AFTER(&state_);
+
return instance;
}