Flutter Engine
fml::WeakPtr< T > Class Template Reference

#include <weak_ptr.h>

Inheritance diagram for fml::WeakPtr< T >:
fml::TaskRunnerAffineWeakPtr< T >

Public Member Functions

 WeakPtr ()
 
 WeakPtr (const WeakPtr< T > &r)=default
 
template<typename U >
 WeakPtr (const WeakPtr< U > &r)
 
 WeakPtr (WeakPtr< T > &&r)=default
 
template<typename U >
 WeakPtr (WeakPtr< U > &&r)
 
virtual ~WeakPtr ()=default
 
WeakPtr< T > & operator= (const WeakPtr< T > &r)=default
 
WeakPtr< T > & operator= (WeakPtr< T > &&r)=default
 
void reset ()
 
 operator bool () const
 
T * get () const
 
T * getUnsafe () const
 
T & operator* () const
 
T * operator-> () const
 

Protected Member Functions

 WeakPtr (T *ptr, fml::RefPtr< fml::internal::WeakPtrFlag > &&flag)
 
virtual void CheckThreadSafety () const
 

Friends

template<typename U >
class WeakPtr
 
class WeakPtrFactory< T >
 

Detailed Description

template<typename T>
class fml::WeakPtr< T >

Definition at line 47 of file weak_ptr.h.

Constructor & Destructor Documentation

◆ WeakPtr() [1/6]

template<typename T>
fml::WeakPtr< T >::WeakPtr ( )
inline

Definition at line 49 of file weak_ptr.h.

49 : ptr_(nullptr) {}

◆ WeakPtr() [2/6]

template<typename T>
fml::WeakPtr< T >::WeakPtr ( const WeakPtr< T > &  r)
explicitdefault

◆ WeakPtr() [3/6]

template<typename T>
template<typename U >
fml::WeakPtr< T >::WeakPtr ( const WeakPtr< U > &  r)
inline

Definition at line 55 of file weak_ptr.h.

56  : ptr_(static_cast<T*>(r.ptr_)), flag_(r.flag_), checker_(r.checker_) {}

◆ WeakPtr() [4/6]

template<typename T>
fml::WeakPtr< T >::WeakPtr ( WeakPtr< T > &&  r)
default

◆ WeakPtr() [5/6]

template<typename T>
template<typename U >
fml::WeakPtr< T >::WeakPtr ( WeakPtr< U > &&  r)
inline

Definition at line 62 of file weak_ptr.h.

63  : ptr_(static_cast<T*>(r.ptr_)),
64  flag_(std::move(r.flag_)),
65  checker_(r.checker_) {}

◆ ~WeakPtr()

template<typename T>
virtual fml::WeakPtr< T >::~WeakPtr ( )
virtualdefault

◆ WeakPtr() [6/6]

template<typename T>
fml::WeakPtr< T >::WeakPtr ( T *  ptr,
fml::RefPtr< fml::internal::WeakPtrFlag > &&  flag 
)
inlineexplicitprotected

Definition at line 118 of file weak_ptr.h.

119  : ptr_(ptr), flag_(std::move(flag)) {}

Member Function Documentation

◆ CheckThreadSafety()

template<typename T>
virtual void fml::WeakPtr< T >::CheckThreadSafety ( ) const
inlineprotectedvirtual

Reimplemented in fml::TaskRunnerAffineWeakPtr< T >, and fml::TaskRunnerAffineWeakPtr< flutter::Rasterizer >.

Definition at line 121 of file weak_ptr.h.

121  {
122  FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker);
123  }
#define FML_DCHECK_CREATION_THREAD_IS_CURRENT(c)

◆ get()

template<typename T>
T* fml::WeakPtr< T >::get ( ) const
inline

Definition at line 88 of file weak_ptr.h.

Referenced by flutter::CopyToBitmap().

88  {
90  return *this ? ptr_ : nullptr;
91  }
virtual void CheckThreadSafety() const
Definition: weak_ptr.h:121

◆ getUnsafe()

template<typename T>
T* fml::WeakPtr< T >::getUnsafe ( ) const
inline

Definition at line 97 of file weak_ptr.h.

97  {
98  // This is an unsafe method to get access to the raw pointer.
99  // We still check the flag_ to determine if the pointer is valid
100  // but callees should note that this WeakPtr could have been
101  // invalidated on another thread.
102  return flag_ && flag_->is_valid() ? ptr_ : nullptr;
103  }

◆ operator bool()

template<typename T>
fml::WeakPtr< T >::operator bool ( ) const
inlineexplicit

Definition at line 83 of file weak_ptr.h.

83  {
85  return flag_ && flag_->is_valid();
86  }
virtual void CheckThreadSafety() const
Definition: weak_ptr.h:121

◆ operator*()

template<typename T>
T& fml::WeakPtr< T >::operator* ( ) const
inline

Definition at line 105 of file weak_ptr.h.

105  {
107  FML_DCHECK(*this);
108  return *get();
109  }
#define FML_DCHECK(condition)
Definition: logging.h:86
virtual void CheckThreadSafety() const
Definition: weak_ptr.h:121

◆ operator->()

template<typename T>
T* fml::WeakPtr< T >::operator-> ( ) const
inline

Definition at line 111 of file weak_ptr.h.

111  {
113  FML_DCHECK(*this);
114  return get();
115  }
#define FML_DCHECK(condition)
Definition: logging.h:86
virtual void CheckThreadSafety() const
Definition: weak_ptr.h:121

◆ operator=() [1/2]

template<typename T>
WeakPtr<T>& fml::WeakPtr< T >::operator= ( const WeakPtr< T > &  r)
default

◆ operator=() [2/2]

template<typename T>
WeakPtr<T>& fml::WeakPtr< T >::operator= ( WeakPtr< T > &&  r)
default

◆ reset()

template<typename T>
void fml::WeakPtr< T >::reset ( )
inline

Definition at line 78 of file weak_ptr.h.

78 { flag_ = nullptr; }

Friends And Related Function Documentation

◆ WeakPtr

template<typename T>
template<typename U >
friend class WeakPtr
friend

Definition at line 127 of file weak_ptr.h.

◆ WeakPtrFactory< T >

template<typename T>
friend class WeakPtrFactory< T >
friend

Definition at line 129 of file weak_ptr.h.


The documentation for this class was generated from the following file: