summaryrefslogtreecommitdiff
path: root/src/node_perf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_perf.cc')
-rw-r--r--src/node_perf.cc18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/node_perf.cc b/src/node_perf.cc
index 97d3a2d995..34e6a35000 100644
--- a/src/node_perf.cc
+++ b/src/node_perf.cc
@@ -182,9 +182,8 @@ void SetupPerformanceObservers(const FunctionCallbackInfo<Value>& args) {
}
// Creates a GC Performance Entry and passes it to observers
-void PerformanceGCCallback(uv_async_t* handle) {
- GCPerformanceEntry* entry = static_cast<GCPerformanceEntry*>(handle->data);
- Environment* env = entry->env();
+void PerformanceGCCallback(Environment* env, void* ptr) {
+ GCPerformanceEntry* entry = static_cast<GCPerformanceEntry*>(ptr);
HandleScope scope(env->isolate());
Local<Context> context = env->context();
@@ -201,10 +200,6 @@ void PerformanceGCCallback(uv_async_t* handle) {
}
delete entry;
- auto closeCB = [](uv_handle_t* handle) {
- delete reinterpret_cast<uv_async_t*>(handle);
- };
- uv_close(reinterpret_cast<uv_handle_t*>(handle), closeCB);
}
// Marks the start of a GC cycle
@@ -221,16 +216,13 @@ void MarkGarbageCollectionEnd(Isolate* isolate,
v8::GCCallbackFlags flags,
void* data) {
Environment* env = static_cast<Environment*>(data);
- uv_async_t* async = new uv_async_t();
- if (uv_async_init(env->event_loop(), async, PerformanceGCCallback))
- return delete async;
- uv_unref(reinterpret_cast<uv_handle_t*>(async));
- async->data =
+ GCPerformanceEntry* entry =
new GCPerformanceEntry(env,
static_cast<PerformanceGCKind>(type),
performance_last_gc_start_mark_,
PERFORMANCE_NOW());
- CHECK_EQ(0, uv_async_send(async));
+ env->SetUnrefImmediate(PerformanceGCCallback,
+ entry);
}