summaryrefslogtreecommitdiffstats
path: root/base/lazy_instance.h
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 11:28:03 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 11:28:03 +0000
commit001b694d745a07e3eb42d6f48e30b8f9f8901138 (patch)
tree4c000504c31b9c7a77d060a49f87537e18ba66a9 /base/lazy_instance.h
parent09e5f47ad0ab092bdf03025eb72c2a29cb9fe2ec (diff)
downloadchromium_src-001b694d745a07e3eb42d6f48e30b8f9f8901138.zip
chromium_src-001b694d745a07e3eb42d6f48e30b8f9f8901138.tar.gz
chromium_src-001b694d745a07e3eb42d6f48e30b8f9f8901138.tar.bz2
Added dynamic annotation files into base/.
Added annotations for atomic reference counting, LazyInstance and Singleton classes. This changelist is a part of an effort of adding ThreadSanitizer support for Chromium. See http://code.google.com/p/data-race-test/wiki/ThreadSanitizer Patch by Timur Iskhodzhanov. Review URL: http://codereview.chromium.org/147008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19353 0039d316-1c4b-4281-b951-d872f2087c98
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;
}