summaryrefslogtreecommitdiffstats
path: root/chromium/v8/include/cppgc/liveness-broker.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/v8/include/cppgc/liveness-broker.h')
-rw-r--r--chromium/v8/include/cppgc/liveness-broker.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/chromium/v8/include/cppgc/liveness-broker.h b/chromium/v8/include/cppgc/liveness-broker.h
index 69dbc11f1f4..883be46240f 100644
--- a/chromium/v8/include/cppgc/liveness-broker.h
+++ b/chromium/v8/include/cppgc/liveness-broker.h
@@ -16,6 +16,30 @@ namespace internal {
class LivenessBrokerFactory;
} // namespace internal
+/**
+ * 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.
+ *
+ * \code
+ * 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 {
+ * visitor->RegisterWeakCallbackMethod<
+ * GCedWithCustomWeakCallback,
+ * &GCedWithCustomWeakCallback::CustomWeakCallbackMethod>(this);
+ * }
+ * };
+ * \endcode
+ */
class V8_EXPORT LivenessBroker final {
public:
template <typename T>
@@ -26,12 +50,6 @@ class V8_EXPORT LivenessBroker final {
}
template <typename T>
- bool IsHeapObjectAlive(const WeakMember<T>& weak_member) const {
- return (weak_member != kSentinelPointer) &&
- IsHeapObjectAlive<T>(weak_member.Get());
- }
-
- template <typename T>
bool IsHeapObjectAlive(const UntracedMember<T>& untraced_member) const {
return (untraced_member != kSentinelPointer) &&
IsHeapObjectAlive<T>(untraced_member.Get());