| 257 | } |
| 258 | |
| 259 | Message *MessageQueue::readMessage() noexcept { |
| 260 | while (!hasNewMessage()) { // if empty |
| 261 | std::unique_lock<std::mutex> lock(_mutex); |
| 262 | pullMessages(); // try pulling data from consumer |
| 263 | if (!hasNewMessage()) { // still empty |
| 264 | _condVar.wait(lock); // wait for the producer to wake me up |
| 265 | pullMessages(); // pulling again |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | Message *const msg = _reader.lastMessage->getNext(); |
| 270 | _reader.lastMessage = msg; |
| 271 | --_reader.newMessageCount; |
| 272 | CC_ASSERT(msg); |
| 273 | return msg; |
| 274 | } |
| 275 | |
| 276 | MessageQueue::~MessageQueue() { |
| 277 | recycleMemoryChunk(_writer.currentMemoryChunk); |
nothing calls this directly
no test coverage detected