| 2312 | } |
| 2313 | |
| 2314 | Status MasterSession::Close() { |
| 2315 | { |
| 2316 | mutex_lock l(mu_); |
| 2317 | closed_ = true; // All subsequent calls to Run() or Extend() will fail. |
| 2318 | } |
| 2319 | cancellation_manager_.StartCancel(); |
| 2320 | std::vector<ReffedClientGraph*> to_unref; |
| 2321 | { |
| 2322 | mutex_lock l(mu_); |
| 2323 | while (num_running_ != 0) { |
| 2324 | num_running_is_zero_.wait(l); |
| 2325 | } |
| 2326 | ClearRunsTable(&to_unref, &run_graphs_); |
| 2327 | ClearRunsTable(&to_unref, &partial_run_graphs_); |
| 2328 | ClearRunsTable(&to_unref, &callables_); |
| 2329 | } |
| 2330 | for (ReffedClientGraph* rcg : to_unref) rcg->Unref(); |
| 2331 | if (should_delete_worker_sessions_) { |
| 2332 | Status s = DeleteWorkerSessions(); |
| 2333 | if (!s.ok()) { |
| 2334 | LOG(WARNING) << s; |
| 2335 | } |
| 2336 | } |
| 2337 | return Status::OK(); |
| 2338 | } |
| 2339 | |
| 2340 | void MasterSession::GarbageCollect() { |
| 2341 | { |