@@ -39,27 +39,33 @@ void RPCServer::SavePort() const {
39
39
port_file.open (file_path);
40
40
port_file << selected_port_;
41
41
port_file.close ();
42
- VLOG (4 ) << " selected port written to " << file_path;
42
+ VLOG (3 ) << " selected port written to " << file_path;
43
43
}
44
44
45
45
void RPCServer::WaitBarrier (const std::string& rpc_name) {
46
+ VLOG (3 ) << " WaitBarrier in: " << rpc_name;
46
47
std::unique_lock<std::mutex> lock (this ->mutex_ );
47
48
barrier_cond_.wait (lock, [this , &rpc_name] {
48
49
return ((barrier_counter_[rpc_name] == client_num_ && client_num_ != 0 ) ||
49
50
exit_flag_.load ());
50
51
});
51
52
52
- VLOG (3 ) << " batch_barrier_ : " << rpc_name << " "
53
- << barrier_counter_[rpc_name];
53
+ VLOG (3 ) << " WaitBarrier out : " << rpc_name
54
+ << " counter: " << barrier_counter_[rpc_name];
54
55
}
55
56
56
57
void RPCServer::IncreaseBatchBarrier (const std::string rpc_name) {
57
- VLOG (4 ) << " RPCServer begin IncreaseBatchBarrier " << rpc_name;
58
+ VLOG (3 ) << " RPCServer begin IncreaseBatchBarrier " << rpc_name;
59
+ // barrier msg should make sure that it's in the right cond(send|recv)
60
+ WaitCond (rpc_name);
58
61
int b = 0 ;
59
62
std::unique_lock<std::mutex> lock (mutex_);
60
63
b = ++barrier_counter_[rpc_name];
64
+ VLOG (3 ) << rpc_name << " barrier_counter: " << b;
61
65
if (b >= client_num_) {
62
66
lock.unlock ();
67
+ VLOG (3 ) << " BatchBarrier counter reach " << client_num_ << " for "
68
+ << rpc_name;
63
69
barrier_cond_.notify_all ();
64
70
lock.lock ();
65
71
}
@@ -71,7 +77,7 @@ void RPCServer::Complete() {
71
77
client_num_--;
72
78
need_reset_all_vars_ = true ;
73
79
74
- VLOG (4 ) << " decrease client_num to: " << client_num_;
80
+ VLOG (3 ) << " decrease client_num to: " << client_num_;
75
81
if (cur_cond_.load () == rpc_cond_map_[kRequestGet ]) {
76
82
barrier_counter_[kRequestGet ]--;
77
83
}
@@ -105,8 +111,8 @@ void RPCServer::RegisterRPC(const std::string& rpc_name,
105
111
106
112
static int cond = -1 ;
107
113
rpc_cond_map_[rpc_name] = ++cond;
108
- VLOG (4 ) << " RegisterRPC rpc_name:" << rpc_name << " , handler:" << handler
109
- << " , cond:" << rpc_cond_map_[rpc_name];
114
+ VLOG (3 ) << " RegisterRPC rpc_name: " << rpc_name << " , handler: " << handler
115
+ << " , cond: " << rpc_cond_map_[rpc_name];
110
116
}
111
117
112
118
void RPCServer::SetCond (const std::string& rpc_name) {
@@ -120,7 +126,7 @@ void RPCServer::SetCond(const std::string& rpc_name) {
120
126
}
121
127
122
128
void RPCServer::WaitCond (const std::string& rpc_name) {
123
- VLOG (4 ) << " RPCServer WaitCond " << rpc_name;
129
+ VLOG (3 ) << " RPCServer WaitCond in " << rpc_name;
124
130
int cond = 0 ;
125
131
{
126
132
std::unique_lock<std::mutex> lock (mutex_);
@@ -130,6 +136,7 @@ void RPCServer::WaitCond(const std::string& rpc_name) {
130
136
std::unique_lock<std::mutex> lock (mutex_);
131
137
rpc_cond_.wait (
132
138
lock, [=] { return (cur_cond_.load () == cond || exit_flag_.load ()); });
139
+ VLOG (3 ) << " RPCServer WaitCond out " << rpc_name;
133
140
}
134
141
135
142
void RPCServer::RegisterVar (const std::string& var_name,
@@ -151,7 +158,7 @@ void RPCServer::RegisterVar(const std::string& var_name,
151
158
}
152
159
153
160
rpc_cond_.notify_all ();
154
- VLOG (4 ) << " RegisterVar context:" << h.String ();
161
+ VLOG (3 ) << " RegisterVar context:" << h.String ();
155
162
}
156
163
157
164
void RPCServer::IncreaseVarBarrier (const std::string& var_name) {
@@ -167,23 +174,23 @@ void RPCServer::IncreaseVarBarrier(const std::string& var_name) {
167
174
barrier_cond_.notify_all ();
168
175
}
169
176
170
- VLOG (4 ) << " IncreaseVarBarrier context:" << h.String ();
177
+ VLOG (3 ) << " IncreaseVarBarrier context:" << h.String ();
171
178
}
172
179
173
180
void RPCServer::WaitVarBarrier (const std::string& var_name) {
174
- VLOG (4 ) << " WaitBarrier var_name:" << var_name;
181
+ VLOG (3 ) << " WaitVarBarrier var_name:" << var_name;
175
182
176
183
std::unique_lock<std::mutex> lock (mutex_);
177
184
barrier_cond_.wait (lock, [&]() {
178
185
return ((var_map_[var_name].barrier_ >= client_num_ && client_num_ != 0 ) ||
179
186
exit_flag_.load ());
180
187
});
181
188
182
- VLOG (4 ) << " WaitBarrier context: " << var_map_[var_name].String ();
189
+ VLOG (3 ) << " WaitVarBarrier context: " << var_map_[var_name].String ();
183
190
}
184
191
185
192
void RPCServer::SetVarCond (const std::string& var_name) {
186
- VLOG (4 ) << " SetVarCond var_name:" << var_name;
193
+ VLOG (3 ) << " SetVarCond var_name:" << var_name;
187
194
{
188
195
std::unique_lock<std::mutex> lock (mutex_);
189
196
if (var_map_.find (var_name) != var_map_.end ()) {
@@ -193,14 +200,14 @@ void RPCServer::SetVarCond(const std::string& var_name) {
193
200
}
194
201
195
202
void RPCServer::WaitVarCond (const std::string& var_name) {
196
- VLOG (4 ) << " WaitVarCond var_name:" << var_name;
203
+ VLOG (3 ) << " WaitVarCond var_name:" << var_name;
197
204
198
205
std::unique_lock<std::mutex> lock (mutex_);
199
206
rpc_cond_.wait (lock, [=] {
200
207
return (var_map_.find (var_name) != var_map_.end () || exit_flag_.load ());
201
208
});
202
209
203
- VLOG (4 ) << " WaitVarCond var_name:" << var_name << " end" ;
210
+ VLOG (3 ) << " WaitVarCond var_name:" << var_name << " end" ;
204
211
}
205
212
206
213
MonomerHandle RPCServer::GetMonomer (const std::string& var_name) {
0 commit comments