| 219 | StatusGroup status_group_ TF_GUARDED_BY(mu_); |
| 220 | |
| 221 | void WhenDone(const Status& s) { |
| 222 | Rendezvous* error_rendez = nullptr; |
| 223 | StatusCallback done = nullptr; |
| 224 | Status status; |
| 225 | |
| 226 | { |
| 227 | mutex_lock l(mu_); |
| 228 | |
| 229 | // If we are the first error encountered, trigger an abort of the |
| 230 | // Rendezvous object by this thread only. |
| 231 | if (status_group_.ok() && !s.ok()) { |
| 232 | error_rendez = rendez_; |
| 233 | error_rendez->Ref(); |
| 234 | } |
| 235 | |
| 236 | if (!s.ok() && !StatusGroup::IsDerived(s) && |
| 237 | !status_group_.HasLogMessages()) { |
| 238 | status_group_.AttachLogMessages(); |
| 239 | } |
| 240 | |
| 241 | status_group_.Update(s); |
| 242 | |
| 243 | // If this is the last call to WhenDone, call the final callback |
| 244 | // below. |
| 245 | if (--pending_ == 0) { |
| 246 | CHECK(done_cb_ != nullptr); |
| 247 | std::swap(done, done_cb_); |
| 248 | status = status_group_.as_summary_status(); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | if (error_rendez != nullptr) { |
| 253 | error_rendez->StartAbort( |
| 254 | errors::Aborted("Stopping remaining executors.")); |
| 255 | error_rendez->Unref(); |
| 256 | } |
| 257 | |
| 258 | if (done != nullptr) { |
| 259 | delete this; |
| 260 | if (!status.ok()) { |
| 261 | VLOG(1) << "ExecutorBarrier finished with bad status: " << status; |
| 262 | } |
| 263 | done(status); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | TF_DISALLOW_COPY_AND_ASSIGN(ExecutorBarrier); |
| 268 | }; |
nothing calls this directly
no test coverage detected