v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
LivenessBroker Class Referencefinal

#include <liveness-broker.h>

Public Member Functions

template<typename T >
bool IsHeapObjectAlive (const T *object) const
 
template<typename T >
bool IsHeapObjectAlive (const WeakMember< T > &weak_member) const
 
template<typename T >
bool IsHeapObjectAlive (const UntracedMember< T > &untraced_member) const
 

Friends

class internal::LivenessBrokerFactory
 

Detailed Description

The broker is passed to weak callbacks to allow (temporarily) querying the liveness state of an object. References to non-live objects must be cleared when IsHeapObjectAlive() returns false.

class GCedWithCustomWeakCallback final
: public GarbageCollected<GCedWithCustomWeakCallback> {
public:
UntracedMember<Bar> bar;
void CustomWeakCallbackMethod(const LivenessBroker& broker) {
if (!broker.IsHeapObjectAlive(bar))
bar = nullptr;
}
void Trace(cppgc::Visitor* visitor) const {
GCedWithCustomWeakCallback,
&GCedWithCustomWeakCallback::CustomWeakCallbackMethod>(this);
}
};

Definition at line 43 of file liveness-broker.h.

Member Function Documentation

◆ IsHeapObjectAlive() [1/3]

bool IsHeapObjectAlive ( const T *  object) const
inline

◆ IsHeapObjectAlive() [2/3]

bool IsHeapObjectAlive ( const UntracedMember< T > &  untraced_member) const
inline

Definition at line 59 of file liveness-broker.h.

References cppgc::kSentinelPointer.

◆ IsHeapObjectAlive() [3/3]

bool IsHeapObjectAlive ( const WeakMember< T > &  weak_member) const
inline

Definition at line 53 of file liveness-broker.h.

References cppgc::kSentinelPointer.

Friends And Related Function Documentation

◆ internal::LivenessBrokerFactory

friend class internal::LivenessBrokerFactory
friend

Definition at line 69 of file liveness-broker.h.


The documentation for this class was generated from the following file:
cppgc::Visitor
Definition: visitor.h:52
cppgc::Visitor::RegisterWeakCallbackMethod
void RegisterWeakCallbackMethod(const T *object)
Definition: visitor.h:142