FastLED 3.9.15
Loading...
Searching...
No Matches

◆ lock()

template<typename T>
Ptr< T > fl::WeakPtr< T >::lock ( ) const
inline

Definition at line 202 of file ptr_impl.h.

202 {
203 if (!mWeakPtr) {
204 return Ptr<T>();
205 }
206 T *out = static_cast<T *>(mWeakPtr->getReferent());
207 if (!out) {
208 // The referent has been destroyed
209 return Ptr<T>();
210 }
211 if (out->ref_count() == 0) {
212 // This is a static object, so the refcount is 0.
213 return Ptr<T>::NoTracking(*out);
214 }
215 // This is a heap object, so we need to ref it.
216 return Ptr<T>::TakeOwnership(static_cast<T *>(out));
217}
static Ptr TakeOwnership(T *ptr)
Definition ptr.h:124
static Ptr NoTracking(T &referent)
Definition ptr.h:130
WeakReferent * mWeakPtr
Definition ptr.h:234

References mWeakPtr, fl::Ptr< T >::NoTracking(), and fl::Ptr< T >::TakeOwnership().

Referenced by fl::string::append(), and operator==().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: