| 473 | } |
| 474 | |
| 475 | bool RuntimeControlService::Start() { |
| 476 | if (running_) return true; |
| 477 | if (pipe_name_.empty()) return false; |
| 478 | |
| 479 | loop_thread_ = std::thread(&RuntimeControlService::EventLoopThread, this); |
| 480 | |
| 481 | std::unique_lock<std::mutex> lock(start_mutex_); |
| 482 | start_cv_.wait(lock, [this] { return loop_ready_; }); |
| 483 | |
| 484 | if (!pipe_connected_) { |
| 485 | if (loop_thread_.joinable()) loop_thread_.join(); |
| 486 | return false; |
| 487 | } |
| 488 | |
| 489 | running_ = true; |
| 490 | return true; |
| 491 | } |
| 492 | |
| 493 | void RuntimeControlService::Stop() { |
| 494 | if (!running_) return; |