#include <Ultralight/RefPtr.h>
template<typename T>
class ultralight::WeakPtr< T >
A weak (non-owning) smart pointer that observes a WeakRefCounted object.
A WeakPtr does not keep its object alive. Use Lock() to atomically obtain a strong RefPtr to the object; the result is null if the object has already been destroyed.
Usage
}
static RefPtr< Bitmap > Create()
Create an empty Bitmap.
A nullable smart pointer.
Definition RefPtr.h:126
friend class WeakPtr
Definition RefPtr.h:521
@ BGRA8_UNORM_SRGB
Blue Green Red Alpha channels, 32-bits per pixel.
Definition Bitmap.h:33
Thread-safe: WeakPtr instances can be created, copied, and destroyed on any thread, and Lock() is race-free against concurrent destruction of the object.
- Note
- T must derive from WeakRefCounted; using WeakPtr with a plain RefCounted type is a compile error.
- Note
- Only construct a WeakPtr from a fully-constructed object: never from this inside a constructor.
◆ WeakPtr() [1/6]
◆ WeakPtr() [2/6]
template<typename T>
| WeakPtr |
( |
std::nullptr_t | | ) |
|
|
inline |
◆ WeakPtr() [3/6]
template<typename T>
template<typename U>
| WeakPtr |
( |
const RefPtr< U > & | strong | ) |
|
|
inline |
Construct a WeakPtr observing the object held by a RefPtr (may be null).
◆ WeakPtr() [4/6]
template<typename T>
template<typename U>
Construct a WeakPtr observing a raw pointer (may be null).
The object must currently be alive: the caller (or another owner) must hold a strong reference to it.
◆ WeakPtr() [5/6]
template<typename T>
| WeakPtr |
( |
const WeakPtr< T > & | other | ) |
|
|
inline |
◆ WeakPtr() [6/6]
template<typename T>
| WeakPtr |
( |
WeakPtr< T > && | other | ) |
|
|
inline |
◆ ~WeakPtr()
◆ Expired()
Whether the observed object has been destroyed (or this WeakPtr is null).
- Warning
- Racy hint only: the object may be destroyed by another thread immediately after this returns false. Never gate a dereference on it; use Lock() instead.
◆ Lock()
Atomically take a strong reference to the observed object.
- Returns
- Returns a RefPtr keeping the object alive, or a null RefPtr if the object has been destroyed (or this WeakPtr is null).
◆ operator=() [1/4]
template<typename T>
template<typename U>
◆ operator=() [2/4]
◆ operator=() [3/4]
template<typename T>
| WeakPtr & operator= |
( |
std::nullptr_t | | ) |
|
|
inline |
◆ operator=() [4/4]
◆ Reset()
Stop observing the object and become a null WeakPtr.
◆ swap()
Exchanges the observed objects of *this and other.
◆ WeakPtr
template<typename T>
template<typename U>
The documentation for this class was generated from the following file: