chenBright commented on code in PR #2280:
URL: https://github.com/apache/brpc/pull/2280#discussion_r1232978741
##########
src/brpc/socket.h:
##########
@@ -292,11 +292,11 @@ friend class policy::H2GlobalStreamCreator;
, pipelined_count(0), auth_flags(0)
, ignore_eovercrowded(false) {}
};
- int Write(butil::IOBuf *msg, const WriteOptions* options = NULL);
+ int Write(butil::IOBuf *msg, const WriteOptions* options = NULL, bool
in_background = false);
Review Comment:
in_background应该是WriteOptions的一项吧,这样是不是合理一点?同时也不用加多一个默认参数了。
##########
src/brpc/controller.cpp:
##########
@@ -1173,14 +1173,16 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
wopt.ignore_eovercrowded = has_flag(FLAGS_IGNORE_EOVERCROWDED);
int rc;
size_t packet_size = 0;
+ // For async RPC, write to socket in background bthread to avoid blocking
current thread.
+ bool write_in_background = _done != nullptr;
Review Comment:
是不是可以在Controller中加一个接口,让用户选择是否要write_in_background?
##########
src/brpc/stream.cpp:
##########
@@ -290,7 +290,9 @@ int Stream::AppendIfNotFull(const butil::IOBuf &data) {
size_t data_length = data.length();
butil::IOBuf copied_data(data);
- const int rc = _fake_socket_weak_ref->Write(&copied_data);
+ // Always write stream message in background bthread to avoid blocking
current thread.
+ bool write_in_background = true;
Review Comment:
同Controller,让用户选择是否要write_in_background?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]