Skip to content

Commit

Permalink
src: move MemoryInfo() for worker code to .cc files
Browse files Browse the repository at this point in the history
This is a) the right thing to do anyway because these functions
can not be inlined by the compiler and b) avoids compilation warnings
in the following commit.

Backport-PR-URL: #32301
PR-URL: #31386
Refs: openjs-foundation/summit#240
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Apr 1, 2020
1 parent 22bf867 commit c2176e1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ void MessagePort::Entangle(MessagePort* a, MessagePortData* b) {
MessagePortData::Entangle(a->data_.get(), b);
}

void MessagePort::MemoryInfo(MemoryTracker* tracker) const {
tracker->TrackField("data", data_);
}

Local<FunctionTemplate> GetMessagePortConstructorTemplate(Environment* env) {
// Factor generating the MessagePort JS constructor into its own piece
// of code, because it is needed early on in the child environment setup.
Expand Down
5 changes: 1 addition & 4 deletions src/node_messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ class MessagePort : public HandleWrap {
// NULL pointer to the C++ MessagePort object is also detached.
inline bool IsDetached() const;

void MemoryInfo(MemoryTracker* tracker) const override {
tracker->TrackField("data", data_);
}

void MemoryInfo(MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(MessagePort)
SET_SELF_SIZE(MessagePort)

Expand Down
4 changes: 4 additions & 0 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ void Worker::Exit(int code) {
}
}

void Worker::MemoryInfo(MemoryTracker* tracker) const {
tracker->TrackField("parent_port", parent_port_);
}

namespace {

// Return the MessagePort that is global for this Environment and communicates
Expand Down
5 changes: 1 addition & 4 deletions src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ class Worker : public AsyncWrap {
// Wait for the worker thread to stop (in a blocking manner).
void JoinThread();

void MemoryInfo(MemoryTracker* tracker) const override {
tracker->TrackField("parent_port", parent_port_);
}

template <typename Fn>
inline bool RequestInterrupt(Fn&& cb);

void MemoryInfo(MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(Worker)
SET_SELF_SIZE(Worker)

Expand Down

0 comments on commit c2176e1

Please sign in to comment.