| 1848 | } |
| 1849 | |
| 1850 | Status MasterSession::Run(CallOptions* opts, const RunStepRequestWrapper& req, |
| 1851 | MutableRunStepResponseWrapper* resp) { |
| 1852 | UpdateLastAccessTime(); |
| 1853 | { |
| 1854 | mutex_lock l(mu_); |
| 1855 | if (closed_) { |
| 1856 | return errors::FailedPrecondition("Session is closed."); |
| 1857 | } |
| 1858 | ++num_running_; |
| 1859 | // Note: all code paths must eventually call MarkRunCompletion() |
| 1860 | // in order to appropriate decrement the num_running_ counter. |
| 1861 | } |
| 1862 | Status status; |
| 1863 | if (!req.partial_run_handle().empty()) { |
| 1864 | status = DoPartialRun(opts, req, resp); |
| 1865 | } else { |
| 1866 | status = DoRunWithLocalExecution(opts, req, resp); |
| 1867 | } |
| 1868 | return status; |
| 1869 | } |
| 1870 | |
| 1871 | // Decrements num_running_ and broadcasts if num_running_ is zero. |
| 1872 | void MasterSession::MarkRunCompletion() { |