Make listener lists threadsafe with a mutex.
PS1 reverts commit 6c8d242b14355bf66c9137e9e4d6c7861d22168f.
PS2 uses an SkMutex for thread safety.
Change-Id: I9318f92cc028844b3dc5a99a00282c2762057895
Reviewed-on: https://skia-review.googlesource.com/155060
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/include/private/SkPathRef.h b/include/private/SkPathRef.h
index e997e56..92568d8 100644
--- a/include/private/SkPathRef.h
+++ b/include/private/SkPathRef.h
@@ -8,10 +8,9 @@
#ifndef SkPathRef_DEFINED
#define SkPathRef_DEFINED
-#include <atomic>
-
#include "SkAtomics.h"
#include "SkMatrix.h"
+#include "SkMutex.h"
#include "SkPoint.h"
#include "SkRRect.h"
#include "SkRect.h"
@@ -313,10 +312,9 @@
struct GenIDChangeListener : SkRefCnt {
virtual ~GenIDChangeListener() {}
virtual void onChange() = 0;
- GenIDChangeListener* next;
};
- void addGenIDChangeListener(sk_sp<GenIDChangeListener>);
+ void addGenIDChangeListener(sk_sp<GenIDChangeListener>); // Threadsafe.
bool isValid() const;
SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
@@ -547,7 +545,8 @@
mutable uint32_t fGenerationID;
SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
- std::atomic<GenIDChangeListener*> fGenIDChangeListeners{nullptr}; // pointers are reffed
+ SkMutex fGenIDChangeListenersMutex;
+ SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are reffed
mutable uint8_t fBoundsIsDirty;
mutable bool fIsFinite; // only meaningful if bounds are valid