Skip to content

Commit 6ecf992

Browse files
authored
[core] [easy] [noop] Add comments on client call (#51614)
Signed-off-by: dentiny <dentinyhao@gmail.com>
1 parent 8978adf commit 6ecf992

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/ray/rpc/client_call.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,12 @@ using PrepareAsyncFunction = std::unique_ptr<grpc::ClientAsyncResponseReader<Rep
186186
/// `ClientCallManager` is used to manage outgoing gRPC requests and the lifecycles of
187187
/// `ClientCall` objects.
188188
///
189-
/// It maintains a thread that keeps polling events from `CompletionQueue`, and post
190-
/// the callback function to the main event loop when a reply is received.
189+
/// It maintains multiple threads that keep polling events from its corresponding
190+
/// `CompletionQueue`, and post the callback function to the main event loop when a reply
191+
/// is received.
191192
///
192-
/// Multiple clients can share one `ClientCallManager`.
193+
/// Multiple clients can share one `ClientCallManager`, with responses delegated to one
194+
/// completion queue in the round-robin style.
193195
class ClientCallManager {
194196
public:
195197
/// Constructor.
@@ -210,7 +212,7 @@ class ClientCallManager {
210212
// Start the polling threads.
211213
cqs_.reserve(num_threads_);
212214
for (int i = 0; i < num_threads_; i++) {
213-
cqs_.push_back(std::make_unique<grpc::CompletionQueue>());
215+
cqs_.emplace_back(std::make_unique<grpc::CompletionQueue>());
214216
polling_threads_.emplace_back(
215217
&ClientCallManager::PollEventsFromCompletionQueue, this, i);
216218
}
@@ -222,6 +224,7 @@ class ClientCallManager {
222224
cq->Shutdown();
223225
}
224226
for (auto &polling_thread : polling_threads_) {
227+
RAY_CHECK(polling_thread.joinable());
225228
polling_thread.join();
226229
}
227230
}

src/ray/rpc/grpc_client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ class GrpcClient {
188188
ClientCallManager &client_call_manager_;
189189
/// The gRPC-generated stub.
190190
std::unique_ptr<typename GrpcService::Stub> stub_;
191-
/// Whether to use TLS.
192-
bool use_tls_;
193191
/// The channel of the stub.
194192
std::shared_ptr<grpc::Channel> channel_;
195193
/// Whether CallMethod is invoked.
196194
std::atomic<bool> call_method_invoked_ = false;
195+
/// Whether to use TLS.
196+
bool use_tls_;
197197
};
198198

199199
} // namespace rpc

0 commit comments

Comments
 (0)