You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ww...@apache.org on 2022/12/28 11:45:45 UTC
[incubator-brpc] branch master updated: Optimize parallel channel request map method (#2057)
This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 98099c88 Optimize parallel channel request map method (#2057)
98099c88 is described below
commit 98099c88d5753c293fd7f26449adf40428038341
Author: caidj <31...@users.noreply.github.com>
AuthorDate: Wed Dec 28 19:45:34 2022 +0800
Optimize parallel channel request map method (#2057)
* optimize parallel channel request map method
* optimize
* optimze request map function
---
src/brpc/parallel_channel.cpp | 2 +-
src/brpc/parallel_channel.h | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/brpc/parallel_channel.cpp b/src/brpc/parallel_channel.cpp
index cf92e710..ca71bedc 100644
--- a/src/brpc/parallel_channel.cpp
+++ b/src/brpc/parallel_channel.cpp
@@ -601,7 +601,7 @@ void ParallelChannel::CallMethod(
for (int i = 0; i < nchan; ++i) {
SubChan& sub_chan = _chans[i];
if (sub_chan.call_mapper != NULL) {
- aps[i] = sub_chan.call_mapper->Map(i, method, request, response);
+ aps[i] = sub_chan.call_mapper->Map(i, nchan, method, request, response);
// Test is_skip first because it implies is_bad.
if (aps[i].is_skip()) {
--ndone;
diff --git a/src/brpc/parallel_channel.h b/src/brpc/parallel_channel.h
index 8e82f600..3ee8d58a 100644
--- a/src/brpc/parallel_channel.h
+++ b/src/brpc/parallel_channel.h
@@ -94,10 +94,23 @@ struct SubCall {
class CallMapper : public SharedObject {
public:
virtual SubCall Map(int channel_index/*starting from 0*/,
+ int channel_count,
const google::protobuf::MethodDescriptor* method,
const google::protobuf::Message* request,
- google::protobuf::Message* response) = 0;
+ google::protobuf::Message* response) {
+ return Map(channel_index, method, request, response);
+ }
+
protected:
+ // TODO: Remove this backward compatibility method.
+ // This method is deprecated. You should override public Map function.
+ virtual SubCall Map(int channel_index/*starting from 0*/,
+ const google::protobuf::MethodDescriptor* method,
+ const google::protobuf::Message* request,
+ google::protobuf::Message* response) {
+ return SubCall::Bad();
+ }
+
// Only callable by subclasses and butil::intrusive_ptr
virtual ~CallMapper() {}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org