summaryrefslogtreecommitdiff
path: root/src/memory_tracker.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-09-29 01:29:07 +0200
committerAnna Henningsen <anna@addaleax.net>2019-11-19 13:47:29 +0100
commit7e6104f1bb63a07885b08f277c3b708caa6b8a23 (patch)
tree32d76e6f055d3bfacd849633db3a8af3868a328c /src/memory_tracker.h
parentefce655c0f1671d0e86b5c89092ac93db983ef94 (diff)
downloadandroid-node-v8-7e6104f1bb63a07885b08f277c3b708caa6b8a23.tar.gz
android-node-v8-7e6104f1bb63a07885b08f277c3b708caa6b8a23.tar.bz2
android-node-v8-7e6104f1bb63a07885b08f277c3b708caa6b8a23.zip
src: introduce custom smart pointers for `BaseObject`s
Referring to `BaseObject` instances using standard C++ smart pointers can interfere with BaseObject’s own cleanup mechanisms (explicit delete, delete-on-GC and delete-on-cleanup). Introducing custom smart pointers allows referring to `BaseObject`s safely while keeping those mechanisms intact. Refs: https://github.com/nodejs/quic/pull/141 Refs: https://github.com/nodejs/quic/pull/149 Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/30374 Refs: https://github.com/nodejs/quic/pull/165 Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/memory_tracker.h')
-rw-r--r--src/memory_tracker.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/memory_tracker.h b/src/memory_tracker.h
index 3bcbe97c99..7e39da5ecf 100644
--- a/src/memory_tracker.h
+++ b/src/memory_tracker.h
@@ -30,6 +30,8 @@ namespace node {
class MemoryTracker;
class MemoryRetainerNode;
+template <typename T, bool kIsWeak>
+class BaseObjectPtrImpl;
namespace crypto {
class NodeBIO;
@@ -138,11 +140,17 @@ class MemoryTracker {
inline void TrackField(const char* edge_name,
const std::unique_ptr<T>& value,
const char* node_name = nullptr);
+
template <typename T>
inline void TrackField(const char* edge_name,
const std::shared_ptr<T>& value,
const char* node_name = nullptr);
+ template <typename T, bool kIsWeak>
+ void TrackField(const char* edge_name,
+ const BaseObjectPtrImpl<T, kIsWeak>& value,
+ const char* node_name = nullptr);
+
// For containers, the elements will be graphed as grandchildren nodes
// if the container is not empty.
// By default, we assume the parent count the stack size of the container