Skip to content

Commit

Permalink
Optimize parallel channel request map method (#2057)
Browse files Browse the repository at this point in the history
* optimize parallel channel request map method

* optimize

* optimze request map function
  • Loading branch information
cdjingit authored Dec 28, 2022
1 parent 6ebe2e9 commit 98099c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/brpc/parallel_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion src/brpc/parallel_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
};
Expand Down

0 comments on commit 98099c8

Please sign in to comment.