Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

src: add Env::profiler_idle_notifier_started() (workers preparation) #93

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ inline Environment::Environment(IsolateData* isolate_data,
v8::Local<v8::Context> context)
: isolate_(context->GetIsolate()),
isolate_data_(isolate_data),
profiler_idle_notifier_started_(false),
async_hooks_(context->GetIsolate()),
timer_base_(uv_now(isolate_data->event_loop())),
using_domains_(false),
Expand Down Expand Up @@ -337,6 +338,10 @@ inline Environment::~Environment() {
free(performance_state_);
}

inline bool Environment::profiler_idle_notifier_started() const {
return profiler_idle_notifier_started_;
}

inline v8::Isolate* Environment::isolate() const {
return isolate_;
}
Expand Down
6 changes: 6 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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()->GetCpuProfiler()->SetIdle(true);
Expand All @@ -123,6 +128,7 @@ void Environment::StartProfilerIdleNotifier() {
}

void Environment::StopProfilerIdleNotifier() {
profiler_idle_notifier_started_ = false;
uv_prepare_stop(&idle_prepare_handle_);
uv_check_stop(&idle_check_handle_);
}
Expand Down
2 changes: 2 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ class Environment {

void StartProfilerIdleNotifier();
void StopProfilerIdleNotifier();
inline bool profiler_idle_notifier_started() const;

inline v8::Isolate* isolate() const;
inline uv_loop_t* event_loop() const;
Expand Down Expand Up @@ -703,6 +704,7 @@ class Environment {
uv_timer_t destroy_async_ids_timer_handle_;
uv_prepare_t idle_prepare_handle_;
uv_check_t idle_check_handle_;
bool profiler_idle_notifier_started_;

AsyncHooks async_hooks_;
DomainFlag domain_flag_;
Expand Down