Shaka Player Embedded
Public Member Functions | Friends | List of all members
shaka::WeakJsPtr< T > Class Template Reference

#include <weak_js_ptr.h>

Inheritance diagram for shaka::WeakJsPtr< T >:
shaka::memory::Traceable

Public Member Functions

 WeakJsPtr ()
 
 WeakJsPtr (std::nullptr_t)
 
template<typename U = T>
 WeakJsPtr (Handle< U > other)
 
 WeakJsPtr (const WeakJsPtr &other)=default
 
 WeakJsPtr (WeakJsPtr &&other)=default
 
WeakJsPtroperator= (const WeakJsPtr &other)=default
 
WeakJsPtroperator= (WeakJsPtr &&other)=default
 
template<typename U = T>
bool operator== (const WeakJsPtr< U > &other) const
 
template<typename U = T>
bool operator== (const Handle< U > &other) const
 
template<typename U = T>
bool operator!= (const WeakJsPtr< U > &other) const
 
template<typename U = T>
bool operator!= (const Handle< U > &other) const
 
bool empty () const
 
Handle< T > handle () const
 
ReturnVal< JsValue > value () const
 
void reset ()
 
template<typename U >
void reset (Handle< U > other)
 
void Trace (memory::HeapTracer *tracer) const override
 
- Public Member Functions inherited from shaka::memory::Traceable
virtual ~Traceable ()
 
virtual bool IsRootedAlive () const
 
virtual bool IsShortLived () const
 

Friends

template<typename >
class WeakJsPtr
 

Additional Inherited Members

- Static Public Attributes inherited from shaka::memory::Traceable
static constexpr const uint64_t kShortLiveDurationMs = 5000
 

Detailed Description

template<typename T>
class shaka::WeakJsPtr< T >

Represents a weak pointer to a JavaScript value. When the GC runs, when this is traced it will mark the value alive so it is not freed. If this is not traced, the GC will free the value.

This MUST be traced. If the GC runs and the object is freed, this object may become invalid. JSC does not keep track of weak pointers, so this must be traced to remain valid.

This is NOT a GenericConverter and should not be used as arguments, fields, etc.. This should only be used in the mapping types to store JavaScript objects.

Definition at line 44 of file weak_js_ptr.h.

Constructor & Destructor Documentation

§ WeakJsPtr() [1/5]

template<typename T>
shaka::WeakJsPtr< T >::WeakJsPtr ( )
inline

Definition at line 46 of file weak_js_ptr.h.

§ WeakJsPtr() [2/5]

template<typename T>
shaka::WeakJsPtr< T >::WeakJsPtr ( std::nullptr_t  )
inline

Definition at line 48 of file weak_js_ptr.h.

§ WeakJsPtr() [3/5]

template<typename T>
template<typename U = T>
shaka::WeakJsPtr< T >::WeakJsPtr ( Handle< U >  other)
inline

Definition at line 51 of file weak_js_ptr.h.

§ WeakJsPtr() [4/5]

template<typename T>
shaka::WeakJsPtr< T >::WeakJsPtr ( const WeakJsPtr< T > &  other)
default

§ WeakJsPtr() [5/5]

template<typename T>
shaka::WeakJsPtr< T >::WeakJsPtr ( WeakJsPtr< T > &&  other)
default

Member Function Documentation

§ empty()

template<typename T>
bool shaka::WeakJsPtr< T >::empty ( ) const
inline
Returns
Whether the pointer is empty.

Definition at line 78 of file weak_js_ptr.h.

§ handle()

template<typename T>
Handle<T> shaka::WeakJsPtr< T >::handle ( ) const
inline
Returns
A local handle to the weak pointer.

Definition at line 87 of file weak_js_ptr.h.

§ operator!=() [1/2]

template<typename T>
template<typename U = T>
bool shaka::WeakJsPtr< T >::operator!= ( const WeakJsPtr< U > &  other) const
inline

Definition at line 69 of file weak_js_ptr.h.

§ operator!=() [2/2]

template<typename T>
template<typename U = T>
bool shaka::WeakJsPtr< T >::operator!= ( const Handle< U > &  other) const
inline

Definition at line 73 of file weak_js_ptr.h.

§ operator=() [1/2]

template<typename T>
WeakJsPtr& shaka::WeakJsPtr< T >::operator= ( const WeakJsPtr< T > &  other)
default

§ operator=() [2/2]

template<typename T>
WeakJsPtr& shaka::WeakJsPtr< T >::operator= ( WeakJsPtr< T > &&  other)
default

§ operator==() [1/2]

template<typename T>
template<typename U = T>
bool shaka::WeakJsPtr< T >::operator== ( const WeakJsPtr< U > &  other) const
inline

Definition at line 61 of file weak_js_ptr.h.

§ operator==() [2/2]

template<typename T>
template<typename U = T>
bool shaka::WeakJsPtr< T >::operator== ( const Handle< U > &  other) const
inline

Definition at line 65 of file weak_js_ptr.h.

§ reset() [1/2]

template<typename T>
void shaka::WeakJsPtr< T >::reset ( )
inline

Definition at line 101 of file weak_js_ptr.h.

§ reset() [2/2]

template<typename T>
template<typename U >
void shaka::WeakJsPtr< T >::reset ( Handle< U >  other)
inline

Definition at line 109 of file weak_js_ptr.h.

§ Trace()

template<typename T>
void shaka::WeakJsPtr< T >::Trace ( memory::HeapTracer tracer) const
inlineoverridevirtual

Called during a GC run. This should call HeapTracer::Trace on all Traceable members. Be sure to call the base method when overriding.

Implements shaka::memory::Traceable.

Definition at line 114 of file weak_js_ptr.h.

§ value()

template<typename T>
ReturnVal<JsValue> shaka::WeakJsPtr< T >::value ( ) const
inline
Returns
A value containing the stored value.

Definition at line 97 of file weak_js_ptr.h.

Friends And Related Function Documentation

§ WeakJsPtr

template<typename T>
template<typename >
friend class WeakJsPtr
friend

Definition at line 133 of file weak_js_ptr.h.


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