Block until a message has been received.
| 188 | |
| 189 | // Block until a message has been received. |
| 190 | Message wait() |
| 191 | { |
| 192 | std::unique_lock<std::mutex> lock(mutex_); |
| 193 | condition_.wait(lock, [this]{ return !message_queue_.empty(); }); |
| 194 | Message msg(std::move(message_queue_.front())); |
| 195 | message_queue_.pop_front(); |
| 196 | return msg; |
| 197 | } |
| 198 | |
| 199 | private: |
| 200 | // Handle a new message by adding it to the queue and waking a waiter. |
no test coverage detected