|
|
|
@ -34,7 +34,7 @@ bool RPCClient::AsyncSendVariable(const std::string& ep,
|
|
|
|
|
const std::string ep_val = ep;
|
|
|
|
|
const std::string var_name_val = var_name;
|
|
|
|
|
const framework::Scope* p_scope = &scope;
|
|
|
|
|
const auto ch = GetChannel(ep_val, ep_val + ":" + var_name_val);
|
|
|
|
|
const auto ch = GetChannel(ep_val);
|
|
|
|
|
|
|
|
|
|
framework::AsyncIO([var_name_val, p_ctx, ep_val, p_scope, time_out, ch,
|
|
|
|
|
this] {
|
|
|
|
@ -88,7 +88,7 @@ bool RPCClient::AsyncGetVariable(const std::string& ep,
|
|
|
|
|
const std::string ep_val = ep;
|
|
|
|
|
const std::string var_name_val = var_name;
|
|
|
|
|
const framework::Scope* p_scope = &scope;
|
|
|
|
|
const auto ch = GetChannel(ep_val, ep_val + ":" + var_name_val);
|
|
|
|
|
const auto ch = GetChannel(ep_val);
|
|
|
|
|
|
|
|
|
|
framework::AsyncIO([var_name_val, ep_val, p_scope, p_ctx, time_out, ch,
|
|
|
|
|
this] {
|
|
|
|
@ -132,7 +132,7 @@ bool RPCClient::AsyncPrefetchVariable(const std::string& ep,
|
|
|
|
|
const std::string in_var_name_val = in_var_name;
|
|
|
|
|
const std::string out_var_name_val = out_var_name;
|
|
|
|
|
const framework::Scope* p_scope = &scope;
|
|
|
|
|
const auto ch = GetChannel(ep_val, ep_val + ":" + in_var_name_val);
|
|
|
|
|
const auto ch = GetChannel(ep_val);
|
|
|
|
|
|
|
|
|
|
framework::AsyncIO([in_var_name_val, out_var_name_val, ep_val, p_scope, p_ctx,
|
|
|
|
|
time_out, ch, this] {
|
|
|
|
@ -165,7 +165,7 @@ bool RPCClient::AsyncPrefetchVariable(const std::string& ep,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCClient::AsyncSendBatchBarrier(const std::string& ep, int64_t time_out) {
|
|
|
|
|
const auto ch = GetChannel(ep, ep);
|
|
|
|
|
const auto ch = GetChannel(ep);
|
|
|
|
|
|
|
|
|
|
BatchBarrierProcessor* s = new BatchBarrierProcessor(ch);
|
|
|
|
|
s->Prepare(time_out);
|
|
|
|
@ -178,7 +178,7 @@ void RPCClient::AsyncSendBatchBarrier(const std::string& ep, int64_t time_out) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCClient::AsyncSendFetchBarrier(const std::string& ep, int64_t time_out) {
|
|
|
|
|
const auto ch = GetChannel(ep, ep);
|
|
|
|
|
const auto ch = GetChannel(ep);
|
|
|
|
|
FetchBarrierProcessor* s = new FetchBarrierProcessor(ch);
|
|
|
|
|
s->Prepare(time_out);
|
|
|
|
|
|
|
|
|
@ -248,10 +248,9 @@ bool RPCClient::Proceed() {
|
|
|
|
|
delete c;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
std::shared_ptr<grpc::Channel> RPCClient::GetChannel(const std::string& ep,
|
|
|
|
|
const std::string& key) {
|
|
|
|
|
std::shared_ptr<grpc::Channel> RPCClient::GetChannel(const std::string& ep) {
|
|
|
|
|
std::unique_lock<std::mutex> lock(mutex_);
|
|
|
|
|
auto it = channels_.find(key);
|
|
|
|
|
auto it = channels_.find(ep);
|
|
|
|
|
if (it != channels_.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
@ -263,7 +262,7 @@ std::shared_ptr<grpc::Channel> RPCClient::GetChannel(const std::string& ep,
|
|
|
|
|
|
|
|
|
|
auto ch =
|
|
|
|
|
grpc::CreateCustomChannel(ep, grpc::InsecureChannelCredentials(), args);
|
|
|
|
|
channels_[key] = ch;
|
|
|
|
|
channels_[ep] = ch;
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|