diff options
author | Timothy Gu <timothygu99@gmail.com> | 2017-09-25 16:28:55 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-06-06 19:43:48 +0200 |
commit | 8939f36630bd718fc0b0b8557cf7f2ed9ecab312 (patch) | |
tree | a5ec7107f61da344772079b8edd10a50fedf1530 | |
parent | 19dae6bd1940c66105f34b4174a77af2355c9e7f (diff) | |
download | android-node-v8-8939f36630bd718fc0b0b8557cf7f2ed9ecab312.tar.gz android-node-v8-8939f36630bd718fc0b0b8557cf7f2ed9ecab312.tar.bz2 android-node-v8-8939f36630bd718fc0b0b8557cf7f2ed9ecab312.zip |
src: add Env::profiler_idle_notifier_started()
Refs: https://github.com/ayojs/ayo/pull/93
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
PR-URL: https://github.com/nodejs/node/pull/20876
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
-rw-r--r-- | src/env-inl.h | 4 | ||||
-rw-r--r-- | src/env.cc | 6 | ||||
-rw-r--r-- | src/env.h | 2 |
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_); } @@ -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_; |