Chromium Code Reviews| Index: include/core/SkRefCnt.h |
| diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h |
| index 28591920a68ba5dc167f44dd3507c3a5ec783648..a9b00838e9d67e967a67cb142af4e3c7caabc6a0 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. |
|
bungeman-skia
2014/02/04 15:20:53
Which TSAN warning?
|
| + // Generally, don't read fRefCnt, and if you do, don't annotate the unprotected read. |
| + 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. |