MCPcopy Create free account
hub / github.com/cocos/cocos-engine / readMessage

Method readMessage

native/cocos/base/threading/MessageQueue.cpp:259–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259Message *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
276MessageQueue::~MessageQueue() {
277 recycleMemoryChunk(_writer.currentMemoryChunk);

Callers

nothing calls this directly

Calls 3

hasNewMessageFunction · 0.85
waitMethod · 0.45
getNextMethod · 0.45

Tested by

no test coverage detected