зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1842658
- Part 2: Use refcounting macros for nsHtml5OwningUTF16Buffer, r=mccr8
When the code was originally added in bug 1842658
, it was to use non-atomic
refcounting across multiple threads due to some invariants preventing
concurrent access. That was changed in bug 1607762 to fix a race issue.
We should be able to switch to using the macros now, which will simplify the
code here a bit.
Depends on D183203
Differential Revision: https://phabricator.services.mozilla.com/D183204
This commit is contained in:
Родитель
ca0d37e8d5
Коммит
b4b30f1acd
|
@ -55,25 +55,3 @@ Span<char16_t> nsHtml5OwningUTF16Buffer::TailAsSpan(int32_t aBufferSize) {
|
|||
void nsHtml5OwningUTF16Buffer::AdvanceEnd(int32_t aNumberOfCodeUnits) {
|
||||
setEnd(getEnd() + aNumberOfCodeUnits);
|
||||
}
|
||||
|
||||
// Not using macros for AddRef and Release in order to be able to refcount on
|
||||
// and create on different threads.
|
||||
|
||||
nsrefcnt nsHtml5OwningUTF16Buffer::AddRef() {
|
||||
MOZ_ASSERT(int32_t(mRefCnt) >= 0, "Illegal refcount.");
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "nsHtml5OwningUTF16Buffer", sizeof(*this));
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsHtml5OwningUTF16Buffer::Release() {
|
||||
MOZ_ASSERT(0 != mRefCnt, "Release without AddRef.");
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsHtml5OwningUTF16Buffer");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include "mozilla/Span.h"
|
||||
|
||||
class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHtml5OwningUTF16Buffer)
|
||||
|
||||
private:
|
||||
/**
|
||||
* Passes a buffer and its length to the superclass constructor.
|
||||
|
@ -56,12 +59,6 @@ class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer {
|
|||
* Add the argument to `end`.
|
||||
*/
|
||||
void AdvanceEnd(int32_t aNumberOfCodeUnits);
|
||||
|
||||
nsrefcnt AddRef();
|
||||
nsrefcnt Release();
|
||||
|
||||
private:
|
||||
mozilla::ThreadSafeAutoRefCnt mRefCnt;
|
||||
};
|
||||
|
||||
#endif // nsHtml5OwningUTF16Buffer_h
|
||||
|
|
Загрузка…
Ссылка в новой задаче