diff --git a/src/ray/common/client_connection.cc b/src/ray/common/client_connection.cc index dde14d680..21588177a 100644 --- a/src/ray/common/client_connection.cc +++ b/src/ray/common/client_connection.cc @@ -206,7 +206,7 @@ ClientConnection::ClientConnection(MessageHandler &message_handler, error_message_type_(error_message_type) {} template -const ClientID &ClientConnection::GetClientId() { +const ClientID &ClientConnection::GetClientId() const { return client_id_; } diff --git a/src/ray/common/client_connection.h b/src/ray/common/client_connection.h index 2aee25681..28bdad5b5 100644 --- a/src/ray/common/client_connection.h +++ b/src/ray/common/client_connection.h @@ -156,7 +156,7 @@ class ClientConnection : public ServerConnection { } /// \return The ClientID of the remote client. - const ClientID &GetClientId(); + const ClientID &GetClientId() const; /// \param client_id The ClientID of the remote client. void SetClientID(const ClientID &client_id); diff --git a/src/ray/raylet/scheduling_resources.h b/src/ray/raylet/scheduling_resources.h index 80b2abea6..daf6372c4 100644 --- a/src/ray/raylet/scheduling_resources.h +++ b/src/ray/raylet/scheduling_resources.h @@ -145,17 +145,17 @@ class ResourceIds { /// /// \param resource_quantity: The total amount of resource. This must either be /// a whole number or a fraction less than 1. - ResourceIds(double resource_quantity); + explicit ResourceIds(double resource_quantity); /// \brief Constructs ResourceIds with a given set of whole IDs. /// /// \param whole_ids: A vector of the resource IDs that are completely available. - ResourceIds(const std::vector &whole_ids); + explicit ResourceIds(const std::vector &whole_ids); /// \brief Constructs ResourceIds with a given set of fractional IDs. /// /// \param fractional_ids: A vector of the resource IDs that are partially available. - ResourceIds(const std::vector> &fractional_ids); + explicit ResourceIds(const std::vector> &fractional_ids); /// \brief Constructs ResourceIds with a given set of whole IDs and fractional IDs. /// diff --git a/src/ray/raylet/worker_pool.cc b/src/ray/raylet/worker_pool.cc index daf928f98..41e056e51 100644 --- a/src/ray/raylet/worker_pool.cc +++ b/src/ray/raylet/worker_pool.cc @@ -144,7 +144,7 @@ void WorkerPool::StartWorkerProcess(const Language &language) { << strerror(errno); } -void WorkerPool::RegisterWorker(std::shared_ptr worker) { +void WorkerPool::RegisterWorker(const std::shared_ptr &worker) { auto pid = worker->Pid(); RAY_LOG(DEBUG) << "Registering worker with pid " << pid; auto &state = GetStateForLanguage(worker->GetLanguage()); @@ -158,7 +158,7 @@ void WorkerPool::RegisterWorker(std::shared_ptr worker) { } } -void WorkerPool::RegisterDriver(std::shared_ptr driver) { +void WorkerPool::RegisterDriver(const std::shared_ptr &driver) { RAY_CHECK(!driver->GetAssignedTaskId().is_nil()); auto &state = GetStateForLanguage(driver->GetLanguage()); state.registered_drivers.insert(std::move(driver)); @@ -186,7 +186,7 @@ std::shared_ptr WorkerPool::GetRegisteredDriver( return nullptr; } -void WorkerPool::PushWorker(std::shared_ptr worker) { +void WorkerPool::PushWorker(const std::shared_ptr &worker) { // Since the worker is now idle, unset its assigned task ID. RAY_CHECK(worker->GetAssignedTaskId().is_nil()) << "Idle workers cannot have an assigned task ID"; @@ -218,13 +218,13 @@ std::shared_ptr WorkerPool::PopWorker(const TaskSpecification &task_spec return worker; } -bool WorkerPool::DisconnectWorker(std::shared_ptr worker) { +bool WorkerPool::DisconnectWorker(const std::shared_ptr &worker) { auto &state = GetStateForLanguage(worker->GetLanguage()); RAY_CHECK(RemoveWorker(state.registered_workers, worker)); return RemoveWorker(state.idle, worker); } -void WorkerPool::DisconnectDriver(std::shared_ptr driver) { +void WorkerPool::DisconnectDriver(const std::shared_ptr &driver) { auto &state = GetStateForLanguage(driver->GetLanguage()); RAY_CHECK(RemoveWorker(state.registered_drivers, driver)); } diff --git a/src/ray/raylet/worker_pool.h b/src/ray/raylet/worker_pool.h index 50d7c8998..ab9ca04ef 100644 --- a/src/ray/raylet/worker_pool.h +++ b/src/ray/raylet/worker_pool.h @@ -57,12 +57,12 @@ class WorkerPool { /// pool after it becomes idle (e.g., requests a work assignment). /// /// \param The Worker to be registered. - void RegisterWorker(std::shared_ptr worker); + void RegisterWorker(const std::shared_ptr &worker); /// Register a new driver. /// /// \param The driver to be registered. - void RegisterDriver(const std::shared_ptr worker); + void RegisterDriver(const std::shared_ptr &worker); /// Get the client connection's registered worker. /// @@ -84,17 +84,17 @@ class WorkerPool { /// /// \param The worker to disconnect. The worker must be registered. /// \return Whether the given worker was in the pool of idle workers. - bool DisconnectWorker(std::shared_ptr worker); + bool DisconnectWorker(const std::shared_ptr &worker); /// Disconnect a registered driver. /// /// \param The driver to disconnect. The driver must be registered. - void DisconnectDriver(std::shared_ptr driver); + void DisconnectDriver(const std::shared_ptr &driver); /// Add an idle worker to the pool. /// /// \param The idle worker to add. - void PushWorker(std::shared_ptr worker); + void PushWorker(const std::shared_ptr &worker); /// Pop an idle worker from the pool. The caller is responsible for pushing /// the worker back onto the pool once the worker has completed its work.