mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1299515 - Make const nsMainThreadPtrHandle<T>
usable. r=erahm
This enables having a const nsMainThreadPtrHandle<T> member which we want to ensure doesn't get assigned to, but whose (the `T`'s) non-const methods are still usable on main thread. Similar to how RefPtr<T> works. MozReview-Commit-ID: 8CG0MwIZmLc --HG-- extra : rebase_source : f0e897d3bf4f9a4d752e964ef63de73a9e710752
This commit is contained in:
parent
99ea5bdb99
commit
f12e78691b
@ -370,14 +370,7 @@ public:
|
||||
// These all call through to nsMainThreadPtrHolder, and thus implicitly
|
||||
// assert that we're on the main thread. Off-main-thread consumers must treat
|
||||
// these handles as opaque.
|
||||
T* get()
|
||||
{
|
||||
if (mPtr) {
|
||||
return mPtr.get()->get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
const T* get() const
|
||||
T* get() const
|
||||
{
|
||||
if (mPtr) {
|
||||
return mPtr.get()->get();
|
||||
@ -385,8 +378,8 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
operator T*() { return get(); }
|
||||
T* operator->() MOZ_NO_ADDREF_RELEASE_ON_RETURN { return get(); }
|
||||
operator T*() const { return get(); }
|
||||
T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return get(); }
|
||||
|
||||
// These are safe to call on other threads with appropriate external locking.
|
||||
bool operator==(const nsMainThreadPtrHandle<T>& aOther) const
|
||||
|
Loading…
Reference in New Issue
Block a user