mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
* fixed #11339 : [v3.6] Crash after hot update. MessageQueue::terminateConsumerThread needs to wait consumer thead to exit. So don't detach consumer thead and we need to join the thread at the end of terminateConsumerThread. * Delete _consumerThead after join.
This commit is contained in:
@@ -124,8 +124,7 @@ void MessageQueue::runConsumerThread() noexcept {
|
||||
_reader.terminateConsumerThread = false;
|
||||
_reader.flushingFinished = false;
|
||||
|
||||
std::thread consumerThread(&MessageQueue::consumerThreadLoop, this);
|
||||
consumerThread.detach();
|
||||
_consumerThread = ccnew std::thread(&MessageQueue::consumerThreadLoop, this);
|
||||
_workerAttached = true;
|
||||
}
|
||||
|
||||
@@ -141,6 +140,13 @@ void MessageQueue::terminateConsumerThread() noexcept {
|
||||
|
||||
kick();
|
||||
event.wait();
|
||||
|
||||
if (_consumerThread != nullptr) {
|
||||
if (_consumerThread->joinable()) {
|
||||
_consumerThread->join();
|
||||
}
|
||||
}
|
||||
CC_SAFE_DELETE(_consumerThread);
|
||||
}
|
||||
|
||||
void MessageQueue::finishWriting() noexcept {
|
||||
|
||||
Reference in New Issue
Block a user