Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize parallel channel request map method #2057

Merged
merged 3 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 11 additions & 1 deletion src/brpc/parallel_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,20 @@ 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.
virtual SubCall Map(int channel_index/*starting from 0*/,
const google::protobuf::MethodDescriptor* method,
const google::protobuf::Message* request,
google::protobuf::Message* response) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个弃用版本还是纯虚函数的话,会不会不利于实现侧向新接口函数迁移?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,没必要是纯虚的了


// Only callable by subclasses and butil::intrusive_ptr
virtual ~CallMapper() {}
};
Expand Down