Skip to content

Commit

Permalink
Don't hold the lock when processing messages, only when taking them o…
Browse files Browse the repository at this point in the history
…ff the queue. Fixes hrydgard#10383
  • Loading branch information
hrydgard authored and orbea committed Dec 10, 2017
1 parent c40c7f3 commit 3a6e837
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,15 +942,18 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
void NativeUpdate() {
PROFILE_END_FRAME();

std::vector<PendingMessage> toProcess;
{
std::lock_guard<std::mutex> lock(pendingMutex);
for (size_t i = 0; i < pendingMessages.size(); i++) {
HandleGlobalMessage(pendingMessages[i].msg, pendingMessages[i].value);
screenManager->sendMessage(pendingMessages[i].msg.c_str(), pendingMessages[i].value.c_str());
}
toProcess = std::move(pendingMessages);
pendingMessages.clear();
}

for (size_t i = 0; i < toProcess.size(); i++) {
HandleGlobalMessage(toProcess[i].msg, toProcess[i].value);
screenManager->sendMessage(toProcess[i].msg.c_str(), toProcess[i].value.c_str());
}

g_DownloadManager.Update();
screenManager->update();
}
Expand Down

0 comments on commit 3a6e837

Please sign in to comment.