v8
9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
ephemeron-pair.h
Go to the documentation of this file.
1
// Copyright 2020 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
ifndef
INCLUDE_CPPGC_EPHEMERON_PAIR_H_
6
#
define
INCLUDE_CPPGC_EPHEMERON_PAIR_H_
7
8
#
include
"cppgc/liveness-broker.h"
9
#
include
"cppgc/member.h"
10
11
namespace
cppgc
{
12
13
/**
14
* An ephemeron pair is used to conditionally retain an object.
15
* The `value` will be kept alive only if the `key` is alive.
16
*/
17
template
<
typename
K,
typename
V>
18
struct
EphemeronPair
{
19
EphemeronPair
(K* k, V* v) :
key
(k),
value
(v) {}
20
WeakMember<K>
key
;
21
Member<V>
value
;
22
23
void
ClearValueIfKeyIsDead
(
const
LivenessBroker& broker) {
24
if
(!broker.IsHeapObjectAlive(
key
))
value
=
nullptr
;
25
}
26
};
27
28
}
// namespace cppgc
29
30
#
endif
// INCLUDE_CPPGC_EPHEMERON_PAIR_H_
cppgc::EphemeronPair
Definition:
ephemeron-pair.h:18
cppgc::EphemeronPair::value
Member< V > value
Definition:
ephemeron-pair.h:21
cppgc::EphemeronPair::ClearValueIfKeyIsDead
void ClearValueIfKeyIsDead(const LivenessBroker &broker)
Definition:
ephemeron-pair.h:23
cppgc
Definition:
allocation.h:17
cppgc::EphemeronPair::key
WeakMember< K > key
Definition:
ephemeron-pair.h:20
cppgc::EphemeronPair::EphemeronPair
EphemeronPair(K *k, V *v)
Definition:
ephemeron-pair.h:19
include
cppgc
ephemeron-pair.h
Generated on Tue Apr 20 2021 15:07:21 for v8 by
1.8.17