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

Unified Diff: skia/config/sk_ref_cnt_ext_debug.h

Issue 1494633002: Fix TSAN error in skia/chromium ref count debug checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build deps Created 5 years 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 | « skia/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/config/sk_ref_cnt_ext_debug.h
diff --git a/skia/config/sk_ref_cnt_ext_debug.h b/skia/config/sk_ref_cnt_ext_debug.h
index b2b66adba729b8110d5b285c7e30cabfaa1af426..78a39a3789f23cb5cbc2a9f23c74a60ec4a5c5ae 100644
--- a/skia/config/sk_ref_cnt_ext_debug.h
+++ b/skia/config/sk_ref_cnt_ext_debug.h
@@ -9,23 +9,31 @@
#error Only one SkRefCnt should be used.
#endif
+#include <atomic>
+
// Alternate implementation of SkRefCnt for Chromium debug builds
class SK_API SkRefCnt : public SkRefCntBase {
public:
- SkRefCnt() : flags_(0) {}
- void ref() const { SkASSERT(flags_ != AdoptionRequired_Flag); SkRefCntBase::ref(); }
+ SkRefCnt();
+ ~SkRefCnt() override;
+ void ref() const { SkASSERT(flags_.load() != AdoptionRequired_Flag); SkRefCntBase::ref(); }
void adopted() const { flags_ |= Adopted_Flag; }
void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
void deref() const { SkRefCntBase::unref(); }
private:
+
enum {
Adopted_Flag = 0x1,
AdoptionRequired_Flag = 0x2,
};
- mutable int flags_;
+ mutable std::atomic<int> flags_;
};
+inline SkRefCnt::SkRefCnt() : flags_(0) { }
+
+inline SkRefCnt::~SkRefCnt() { }
+
// Bootstrap for Blink's WTF::RefPtr
namespace WTF {
« no previous file with comments | « skia/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698