diff --git a/src/mock/ray/core_worker/memory_store.h b/src/mock/ray/core_worker/memory_store.h index 0a071c75f593..d524d5883487 100644 --- a/src/mock/ray/core_worker/memory_store.h +++ b/src/mock/ray/core_worker/memory_store.h @@ -25,16 +25,14 @@ class DefaultCoreWorkerMemoryStoreWithThread : public CoreWorkerMemoryStore { std::unique_ptr io_context = std::make_unique( "DefaultCoreWorkerMemoryStoreWithThread"); - return std::unique_ptr( - new DefaultCoreWorkerMemoryStoreWithThread(std::move(io_context))); + return std::make_unique(std::move(io_context)); } static std::shared_ptr CreateShared() { std::unique_ptr io_context = std::make_unique( "DefaultCoreWorkerMemoryStoreWithThread"); - return std::shared_ptr( - new DefaultCoreWorkerMemoryStoreWithThread(std::move(io_context))); + return std::make_shared(std::move(io_context)); } ~DefaultCoreWorkerMemoryStoreWithThread() { io_context_->Stop(); } diff --git a/src/ray/common/client_connection.cc b/src/ray/common/client_connection.cc index 194d8d133e24..b14a09be1fbb 100644 --- a/src/ray/common/client_connection.cc +++ b/src/ray/common/client_connection.cc @@ -115,6 +115,8 @@ Status ConnectSocketRetry(local_stream_socket &socket, } std::shared_ptr ServerConnection::Create(local_stream_socket &&socket) { + // C++ limitation: std::make_shared cannot be used because std::shared_ptr cannot invoke + // protected constructors. std::shared_ptr self(new ServerConnection(std::move(socket))); return self; } @@ -417,6 +419,8 @@ std::shared_ptr ClientConnection::Create( const std::string &debug_label, const std::vector &message_type_enum_names, int64_t error_message_type) { + // C++ limitation: std::make_shared cannot be used because std::shared_ptr cannot invoke + // protected constructors. std::shared_ptr self(new ClientConnection(message_handler, std::move(socket), debug_label, diff --git a/src/ray/common/test_util.cc b/src/ray/common/test_util.cc index 45f5963b6b9e..9eed7903b8f1 100644 --- a/src/ray/common/test_util.cc +++ b/src/ray/common/test_util.cc @@ -261,7 +261,7 @@ std::shared_ptr GenerateRandomObject( ref.set_object_id(inlined_id.Binary()); refs.push_back(ref); } - return std::shared_ptr(new RayObject(GenerateRandomBuffer(), nullptr, refs)); + return std::make_shared(GenerateRandomBuffer(), nullptr, refs); } /// Path to redis server executable binary. diff --git a/src/ray/raylet/node_manager.cc b/src/ray/raylet/node_manager.cc index 1bbd1287dd1a..ed52e7313370 100644 --- a/src/ray/raylet/node_manager.cc +++ b/src/ray/raylet/node_manager.cc @@ -413,8 +413,7 @@ std::shared_ptr NodeManager::CreateRayletClient( rpc::NodeManagerWorkerClient::make(node_info->node_manager_address(), node_info->node_manager_port(), client_call_manager); - return std::shared_ptr( - new raylet::RayletClient(std::move(grpc_client))); + return std::make_shared(std::move(grpc_client)); }; bool NodeManager::IsWorkerDead(const WorkerID &worker_id, const NodeID &node_id) const { diff --git a/src/ray/rpc/node_manager/node_manager_client.h b/src/ray/rpc/node_manager/node_manager_client.h index 47fb67a9fc3d..9e578737431c 100644 --- a/src/ray/rpc/node_manager/node_manager_client.h +++ b/src/ray/rpc/node_manager/node_manager_client.h @@ -73,6 +73,8 @@ class NodeManagerWorkerClient const std::string &address, const int port, ClientCallManager &client_call_manager) { + // C++ limitation: std::make_shared cannot be used because std::shared_ptr cannot invoke + // private constructors. auto instance = new NodeManagerWorkerClient(address, port, client_call_manager); return std::shared_ptr(instance); } diff --git a/src/ray/rpc/retryable_grpc_client.h b/src/ray/rpc/retryable_grpc_client.h index 290a027b2fd7..8833a68fbfa4 100644 --- a/src/ray/rpc/retryable_grpc_client.h +++ b/src/ray/rpc/retryable_grpc_client.h @@ -120,6 +120,8 @@ class RetryableGrpcClient : public std::enable_shared_from_this server_unavailable_timeout_callback, std::string server_name) { + // C++ limitation: std::make_shared cannot be used because std::shared_ptr cannot invoke + // private constructors. return std::shared_ptr( new RetryableGrpcClient(std::move(channel), io_context, @@ -267,6 +269,8 @@ RetryableGrpcClient::RetryableGrpcRequest::Create( }; return std::shared_ptr( + // C++ limitation: std::make_shared cannot be used because std::shared_ptr cannot invoke + // private constructors. new RetryableGrpcClient::RetryableGrpcRequest( std::move(executor), std::move(failure_callback), request_bytes, timeout_ms)); }