GeezerVison is showing github.com — src: add Env::profiler_idle_notifier_started() · nodejs/node@314b47d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/env-inl.h +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -322,6 +322,10 @@ inline Environment* Environment::GetThreadLocalEnv() { |
322 | 322 | return static_cast<Environment*>(uv_key_get(&thread_local_env)); |
323 | 323 | } |
324 | 324 |
|
| 325 | +inline bool Environment::profiler_idle_notifier_started() const { |
| 326 | + return profiler_idle_notifier_started_; |
| 327 | +} |
| 328 | + |
325 | 329 | inline v8::Isolate* Environment::isolate() const { |
326 | 330 | return isolate_; |
327 | 331 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: src/env.cc +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -263,6 +263,11 @@ void Environment::CleanupHandles() { |
263 | 263 | } |
264 | 264 |
|
265 | 265 | void Environment::StartProfilerIdleNotifier() { |
| 266 | + if (profiler_idle_notifier_started_) |
| 267 | + return; |
| 268 | + |
| 269 | + profiler_idle_notifier_started_ = true; |
| 270 | + |
266 | 271 | uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) { |
267 | 272 | Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle); |
268 | 273 | env->isolate()->SetIdle(true); |
@@ -275,6 +280,7 @@ void Environment::StartProfilerIdleNotifier() { |
275 | 280 | } |
276 | 281 |
|
277 | 282 | void Environment::StopProfilerIdleNotifier() { |
| 283 | + profiler_idle_notifier_started_ = false; |
278 | 284 | uv_prepare_stop(&idle_prepare_handle_); |
279 | 285 | uv_check_stop(&idle_check_handle_); |
280 | 286 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: src/env.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -615,6 +615,7 @@ class Environment { |
615 | 615 |
|
616 | 616 | void StartProfilerIdleNotifier(); |
617 | 617 | void StopProfilerIdleNotifier(); |
| 618 | + inline bool profiler_idle_notifier_started() const; |
618 | 619 |
|
619 | 620 | inline v8::Isolate* isolate() const; |
620 | 621 | inline tracing::Agent* tracing_agent() const; |
@@ -840,6 +841,7 @@ class Environment { |
840 | 841 | uv_idle_t immediate_idle_handle_; |
841 | 842 | uv_prepare_t idle_prepare_handle_; |
842 | 843 | uv_check_t idle_check_handle_; |
| 844 | + bool profiler_idle_notifier_started_ = false; |
843 | 845 |
|
844 | 846 | AsyncHooks async_hooks_; |
845 | 847 | ImmediateInfo immediate_info_; |
|