summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/env-inl.h4
-rw-r--r--src/env.cc6
-rw-r--r--src/env.h2
3 files changed, 12 insertions, 0 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index aadb81271c..50328bd77c 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -322,6 +322,10 @@ inline Environment* Environment::GetThreadLocalEnv() {
return static_cast<Environment*>(uv_key_get(&thread_local_env));
}
+inline bool Environment::profiler_idle_notifier_started() const {
+ return profiler_idle_notifier_started_;
+}
+
inline v8::Isolate* Environment::isolate() const {
return isolate_;
}
diff --git a/src/env.cc b/src/env.cc
index cb514828d2..090b43968b 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -263,6 +263,11 @@ void Environment::CleanupHandles() {
}
void Environment::StartProfilerIdleNotifier() {
+ if (profiler_idle_notifier_started_)
+ return;
+
+ profiler_idle_notifier_started_ = true;
+
uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) {
Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle);
env->isolate()->SetIdle(true);
@@ -275,6 +280,7 @@ void Environment::StartProfilerIdleNotifier() {
}
void Environment::StopProfilerIdleNotifier() {
+ profiler_idle_notifier_started_ = false;
uv_prepare_stop(&idle_prepare_handle_);
uv_check_stop(&idle_check_handle_);
}
diff --git a/src/env.h b/src/env.h
index f1e9ccaef2..cdb592732a 100644
--- a/src/env.h
+++ b/src/env.h
@@ -615,6 +615,7 @@ class Environment {
void StartProfilerIdleNotifier();
void StopProfilerIdleNotifier();
+ inline bool profiler_idle_notifier_started() const;
inline v8::Isolate* isolate() const;
inline tracing::Agent* tracing_agent() const;
@@ -840,6 +841,7 @@ class Environment {
uv_idle_t immediate_idle_handle_;
uv_prepare_t idle_prepare_handle_;
uv_check_t idle_check_handle_;
+ bool profiler_idle_notifier_started_ = false;
AsyncHooks async_hooks_;
ImmediateInfo immediate_info_;