| 32 | namespace test { |
| 33 | |
| 34 | void ServerThread::start() { |
| 35 | assert(!running_); |
| 36 | running_ = true; |
| 37 | |
| 38 | helper_.reset(new Helper(this)); |
| 39 | |
| 40 | // Start the other thread |
| 41 | concurrency::ThreadFactory threadFactory; |
| 42 | threadFactory.setDetached(false); |
| 43 | thread_ = threadFactory.newThread(helper_); |
| 44 | |
| 45 | thread_->start(); |
| 46 | |
| 47 | // Wait on the other thread to tell us that it has successfully |
| 48 | // bound to the port and started listening (or until an error occurs). |
| 49 | concurrency::Synchronized s(serverMonitor_); |
| 50 | while (!serving_ && !error_) { |
| 51 | serverMonitor_.waitForever(); |
| 52 | } |
| 53 | |
| 54 | if (error_) { |
| 55 | throw transport::TTransportException(transport::TTransportException::NOT_OPEN, |
| 56 | "failed to bind on server socket"); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | void ServerThread::stop() { |
| 61 | if (!running_) { |
no test coverage detected