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 { |