Skip to content

Commit d395657

Browse files
committed
Addressing simpler points of review feedback
1 parent 032ee36 commit d395657

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

bindings/profilers/wall.cc

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ using namespace v8;
5858

5959
namespace dd {
6060

61-
using ContextPtr = std::shared_ptr<Global<Value>>;
62-
6361
// Maximum number of rounds in the GetV8ToEpochOffset
6462
static constexpr int MAX_EPOCH_OFFSET_ATTEMPTS = 20;
6563

@@ -613,11 +611,9 @@ void WallProfiler::Dispose(Isolate* isolate, bool removeFromMap) {
613611
node::RemoveEnvironmentCleanupHook(
614612
isolate, &WallProfiler::CleanupHook, isolate);
615613

616-
for (auto it = liveContextPtrs_.begin(); it != liveContextPtrs_.end();) {
617-
auto ptr = *it;
614+
for (auto ptr : liveContextPtrs_) {
618615
ptr->UnregisterFromGC();
619616
delete ptr;
620-
++it;
621617
}
622618
liveContextPtrs_.clear();
623619
deadContextPtrs_.clear();
@@ -1086,11 +1082,9 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
10861082
}
10871083

10881084
// Clean up dead context pointers
1089-
for (auto it = deadContextPtrs_.begin(); it != deadContextPtrs_.end();) {
1090-
auto ptr = *it;
1085+
for (auto ptr : deadContextPtrs_) {
10911086
liveContextPtrs_.erase(ptr);
10921087
delete ptr;
1093-
++it;
10941088
}
10951089
deadContextPtrs_.clear();
10961090

@@ -1113,11 +1107,11 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
11131107
contextPtr = new PersistentContextPtr(&deadContextPtrs_);
11141108

11151109
auto external = External::New(isolate, contextPtr);
1116-
setInProgress.store(true, std::memory_order_relaxed);
1110+
setInProgress_.store(true, std::memory_order_relaxed);
11171111
std::atomic_signal_fence(std::memory_order_release);
11181112
auto maybeSetResult = cpedObj->SetPrivate(v8Ctx, localSymbol, external);
11191113
std::atomic_signal_fence(std::memory_order_release);
1120-
setInProgress.store(false, std::memory_order_relaxed);
1114+
setInProgress_.store(false, std::memory_order_relaxed);
11211115
if (maybeSetResult.IsNothing()) {
11221116
delete contextPtr;
11231117
return;
@@ -1136,7 +1130,7 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
11361130
}
11371131

11381132
ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
1139-
auto isSetInProgress = setInProgress.load(std::memory_order_relaxed);
1133+
auto isSetInProgress = setInProgress_.load(std::memory_order_relaxed);
11401134
std::atomic_signal_fence(std::memory_order_acquire);
11411135
if (isSetInProgress) {
11421136
// New sample context is being set. Safe behavior is to not try attempt
@@ -1148,7 +1142,7 @@ ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
11481142
auto curGcCount = gcCount.load(std::memory_order_relaxed);
11491143
std::atomic_signal_fence(std::memory_order_acquire);
11501144
if (curGcCount > 0) {
1151-
return gcContext;
1145+
return gcContext_;
11521146
}
11531147
}
11541148

@@ -1253,7 +1247,7 @@ void WallProfiler::OnGCStart(v8::Isolate* isolate) {
12531247
gcAsyncId = GetAsyncIdNoGC(isolate);
12541248
}
12551249
if (useCPED_) {
1256-
gcContext = GetContextPtrSignalSafe(isolate);
1250+
gcContext_ = GetContextPtrSignalSafe(isolate);
12571251
}
12581252
}
12591253
gcCount.store(curCount + 1, std::memory_order_relaxed);
@@ -1268,7 +1262,7 @@ void WallProfiler::OnGCEnd() {
12681262
if (newCount == 0) {
12691263
gcAsyncId = -1;
12701264
if (useCPED_) {
1271-
gcContext.reset();
1265+
gcContext_.reset();
12721266
}
12731267
}
12741268
}

bindings/profilers/wall.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class WallProfiler : public Nan::ObjectWrap {
9797
std::vector<PersistentContextPtr*> deadContextPtrs_;
9898

9999
std::atomic<int> gcCount = 0;
100-
std::atomic<bool> setInProgress = false;
100+
std::atomic<bool> setInProgress_ = false;
101101
double gcAsyncId;
102-
ContextPtr gcContext;
102+
ContextPtr gcContext_;
103103

104104
std::atomic<CollectionMode> collectionMode_;
105105
std::atomic<uint64_t> noCollectCallCount_;

0 commit comments

Comments
 (0)