| 409 | } |
| 410 | |
| 411 | Status GrpcServer::Join() { |
| 412 | mutex_lock l(mu_); |
| 413 | switch (state_) { |
| 414 | case NEW: |
| 415 | // Prevent the server from being started subsequently. |
| 416 | state_ = STOPPED; |
| 417 | return Status::OK(); |
| 418 | case STARTED: |
| 419 | case STOPPED: |
| 420 | master_thread_.reset(); |
| 421 | worker_thread_.reset(); |
| 422 | eager_thread_.reset(); |
| 423 | return Status::OK(); |
| 424 | default: |
| 425 | LOG(FATAL); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | const string GrpcServer::target() const { |
| 430 | return strings::StrCat("grpc://localhost:", bound_port_); |