Skip to content

Commit

Permalink
VideoCommon/OnScreenDisplay: Use deduction guides for std::lock_guard
Browse files Browse the repository at this point in the history
Same behavior without hardcoding the type of the mutex within the lock
guards. This means the type of the mutex would be able to be changed
without needing to also change all occurrences lock guards are used.
  • Loading branch information
lioncash committed Jul 29, 2019
1 parent a565e41 commit 3f947f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/Core/VideoCommon/OnScreenDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position,

void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 rgba)
{
std::lock_guard<std::mutex> lock(s_messages_mutex);
std::lock_guard lock{s_messages_mutex};
s_messages.erase(type);
s_messages.emplace(type, Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba));
}

void AddMessage(std::string message, u32 ms, u32 rgba)
{
std::lock_guard<std::mutex> lock(s_messages_mutex);
std::lock_guard lock{s_messages_mutex};
s_messages.emplace(MessageType::Typeless,
Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba));
}
Expand All @@ -98,7 +98,7 @@ void DrawMessages()
return;

{
std::lock_guard<std::mutex> lock(s_messages_mutex);
std::lock_guard lock{s_messages_mutex};

const u32 now = Common::Timer::GetTimeMs();
float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x;
Expand All @@ -122,7 +122,7 @@ void DrawMessages()

void ClearMessages()
{
std::lock_guard<std::mutex> lock(s_messages_mutex);
std::lock_guard lock{s_messages_mutex};
s_messages.clear();
}
} // namespace OSD

0 comments on commit 3f947f0

Please sign in to comment.