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

Unified Diff: include/core/SkRefCnt.h

Issue 144953005: TSAN: use somewhat pithier SK_ANNOTATE_UNPROTECTED_READ. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: benh Created 6 years, 10 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 | « include/core/SkOnce.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRefCnt.h
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 28591920a68ba5dc167f44dd3507c3a5ec783648..e4524beff7aed72e346b6289e25525c0e8a14ba0 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -10,6 +10,7 @@
#ifndef SkRefCnt_DEFINED
#define SkRefCnt_DEFINED
+#include "SkDynamicAnnotations.h"
#include "SkThread.h"
#include "SkInstCnt.h"
#include "SkTemplates.h"
@@ -44,11 +45,13 @@ public:
/** Return the reference count. Use only for debugging. */
int32_t getRefCnt() const { return fRefCnt; }
- /** Returns true if the caller is the only owner.
+ /** May return true if the caller is the only owner.
* Ensures that all previous owner's actions are complete.
*/
bool unique() const {
- bool const unique = (1 == fRefCnt);
+ // We believe we're reading fRefCnt in a safe way here, so we stifle the TSAN warning about
+ // an unproctected read. Generally, don't read fRefCnt, and don't stifle this warning.
bungeman-skia 2014/02/04 17:21:39 nit: two spaces after the period.
+ bool const unique = (1 == SK_ANNOTATE_UNPROTECTED_READ(fRefCnt));
if (unique) {
// Acquire barrier (L/SL), if not provided by load of fRefCnt.
// Prevents user's 'unique' code from happening before decrements.
« no previous file with comments | « include/core/SkOnce.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698