diff --git a/src/ray/core_worker/core_worker.cc b/src/ray/core_worker/core_worker.cc index 61cfc95b8..f5592a88b 100644 --- a/src/ray/core_worker/core_worker.cc +++ b/src/ray/core_worker/core_worker.cc @@ -51,8 +51,8 @@ CoreWorker::CoreWorker( RAY_CHECK_OK(gcs_client_->Connect(io_service_)); // Initialize profiler. - profiler_ = std::unique_ptr( - new worker::Profiler(worker_context_, node_ip_address, io_service_, gcs_client_)); + profiler_ = std::make_shared(worker_context_, node_ip_address, + io_service_, gcs_client_); object_interface_ = std::unique_ptr(new CoreWorkerObjectInterface( diff --git a/src/ray/core_worker/core_worker.h b/src/ray/core_worker/core_worker.h index 0364c6f2f..6ee3fcc8c 100644 --- a/src/ray/core_worker/core_worker.h +++ b/src/ray/core_worker/core_worker.h @@ -101,7 +101,7 @@ class CoreWorker { boost::asio::io_service::work io_work_; std::thread io_thread_; - std::unique_ptr profiler_; + std::shared_ptr profiler_; std::unique_ptr raylet_client_; std::unique_ptr gcs_client_; std::unique_ptr task_interface_; diff --git a/src/ray/core_worker/profiling.cc b/src/ray/core_worker/profiling.cc index 36700b042..847d55d01 100644 --- a/src/ray/core_worker/profiling.cc +++ b/src/ray/core_worker/profiling.cc @@ -6,7 +6,7 @@ namespace ray { namespace worker { -ProfileEvent::ProfileEvent(const std::unique_ptr &profiler, +ProfileEvent::ProfileEvent(const std::shared_ptr profiler, const std::string &event_type) : profiler_(profiler) { rpc_event_.set_event_type(event_type); diff --git a/src/ray/core_worker/profiling.h b/src/ray/core_worker/profiling.h index 056571552..8be39ae0f 100644 --- a/src/ray/core_worker/profiling.h +++ b/src/ray/core_worker/profiling.h @@ -37,7 +37,7 @@ class Profiler { class ProfileEvent { public: - ProfileEvent(const std::unique_ptr &profiler, const std::string &event_type); + ProfileEvent(const std::shared_ptr profiler, const std::string &event_type); ~ProfileEvent() { rpc_event_.set_end_time(current_sys_time_seconds()); @@ -49,7 +49,7 @@ class ProfileEvent { } private: - const std::unique_ptr &profiler_; + const std::shared_ptr profiler_; rpc::ProfileTableData::ProfileEvent rpc_event_; };