Core: Use C++17 deduction guides with locked recursive mutexes

Cleans up some locks that explicitly specify the recursive mutex type in
it. Meant to be included with the previous commit that cleaned out
regular mutexes, but I forgot.
This commit is contained in:
Lioncash 2020-12-29 18:31:29 -05:00
parent 3b2e31230f
commit e527b69d54
3 changed files with 36 additions and 36 deletions

View File

@ -20,7 +20,7 @@ FifoRecorder::FifoRecorder() = default;
void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
{
std::lock_guard<std::recursive_mutex> lk(m_mutex);
std::lock_guard lk(m_mutex);
m_File = std::make_unique<FifoDataFile>();
@ -57,7 +57,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
void FifoRecorder::StopRecording()
{
std::lock_guard<std::recursive_mutex> lk(m_mutex);
std::lock_guard lk(m_mutex);
m_RequestedRecordingEnd = true;
}
@ -97,7 +97,7 @@ void FifoRecorder::WriteGPCommand(const u8* data, u32 size)
m_CurrentFrame.fifoData = m_FifoData;
{
std::lock_guard<std::recursive_mutex> lk(m_mutex);
std::lock_guard lk(m_mutex);
// Copy frame to file
// The file will be responsible for freeing the memory allocated for each frame's fifoData
@ -155,7 +155,7 @@ void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, boo
void FifoRecorder::EndFrame(u32 fifoStart, u32 fifoEnd)
{
// m_IsRecording is assumed to be true at this point, otherwise this function would not be called
std::lock_guard<std::recursive_mutex> lk(m_mutex);
std::lock_guard lk(m_mutex);
m_FrameEnded = true;
@ -198,7 +198,7 @@ void FifoRecorder::EndFrame(u32 fifoStart, u32 fifoEnd)
void FifoRecorder::SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32* xfMem,
const u32* xfRegs, u32 xfRegsSize, const u8* texMem)
{
std::lock_guard<std::recursive_mutex> lk(m_mutex);
std::lock_guard lk(m_mutex);
if (m_File)
{

View File

@ -324,7 +324,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
player.revision);
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
m_players[player.pid] = player;
}
@ -340,7 +340,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> pid;
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
const auto it = m_players.find(pid);
if (it == m_players.end())
break;
@ -591,7 +591,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
{
std::string netplay_name;
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
ReceiveSyncIdentifier(packet, m_selected_game);
packet >> netplay_name;
}
@ -623,7 +623,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> pid;
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
Player& player = m_players[pid];
u32 status;
packet >> status;
@ -637,7 +637,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_START_GAME:
{
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
packet >> m_current_game;
packet >> m_net_settings.m_CPUthread;
@ -767,7 +767,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> pid;
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
Player& player = m_players[pid];
packet >> player.ping;
}
@ -785,7 +785,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> frame;
std::string player = "??";
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
{
auto it = m_players.find(pid_to_blame);
if (it != m_players.end())
@ -808,7 +808,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
}
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
memcpy(&g_SRAM.settings, sram, sram_settings_len);
g_SRAM_netplay_initialized = true;
}
@ -1305,7 +1305,7 @@ void NetPlayClient::Disconnect()
void NetPlayClient::SendAsync(sf::Packet&& packet, const u8 channel_id)
{
{
std::lock_guard<std::recursive_mutex> lkq(m_crit.async_queue_write);
std::lock_guard lkq(m_crit.async_queue_write);
m_async_queue.Push(AsyncQueueEntry{std::move(packet), channel_id});
}
ENetUtil::WakeupThread(m_client);
@ -1376,7 +1376,7 @@ void NetPlayClient::ThreadFunc()
// called from ---GUI--- thread
void NetPlayClient::GetPlayerList(std::string& list, std::vector<int>& pid_list)
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
std::ostringstream ss;
@ -1432,7 +1432,7 @@ void NetPlayClient::GetPlayerList(std::string& list, std::vector<int>& pid_list)
// called from ---GUI--- thread
std::vector<const Player*> NetPlayClient::GetPlayers()
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
std::vector<const Player*> players;
for (const auto& pair : m_players)
@ -1499,7 +1499,7 @@ void NetPlayClient::SendStopGamePacket()
// called from ---GUI--- thread
bool NetPlayClient::StartGame(const std::string& path)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
SendStartGamePacket();
if (m_is_running.IsSet())
@ -1950,7 +1950,7 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const std::size_t size,
WiimoteInput nw;
nw.report_id = reporting_mode;
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
// Only send data, if this Wiimote is mapped to this player
if (m_wiimote_map[_number] == m_local_player->pid)
@ -2213,7 +2213,7 @@ void NetPlayClient::RequestGolfControl()
// called from ---GUI--- thread
std::string NetPlayClient::GetCurrentGolfer()
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
if (m_players.count(m_current_golfer))
return m_players[m_current_golfer].name;
return "";
@ -2309,7 +2309,7 @@ void NetPlayClient::SendTimeBase()
bool NetPlayClient::DoAllPlayersHaveGame()
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
return std::all_of(std::begin(m_players), std::end(m_players), [](auto entry) {
return entry.second.game_status == SyncIdentifierComparison::SameGame;

View File

@ -253,7 +253,7 @@ void NetPlayServer::ThreadFunc()
while (!m_async_queue.Empty())
{
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
auto& e = m_async_queue.Front();
if (e.target_mode == TargetMode::Only)
{
@ -289,7 +289,7 @@ void NetPlayServer::ThreadFunc()
// uninitialized client, we'll assume this is their initialization packet
unsigned int error;
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
error = OnConnect(netEvent.peer, rpac);
}
@ -311,7 +311,7 @@ void NetPlayServer::ThreadFunc()
if (OnData(rpac, client) != 0)
{
// if a bad packet is received, disconnect the client
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
OnDisconnect(client);
ClearPeerPlayerId(netEvent.peer);
@ -322,7 +322,7 @@ void NetPlayServer::ThreadFunc()
break;
case ENET_EVENT_TYPE_DISCONNECT:
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
if (!netEvent.peer->data)
break;
auto it = m_players.find(*PeerPlayerId(netEvent.peer));
@ -471,7 +471,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
// add client to the player list
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
m_players.emplace(*PeerPlayerId(player.socket), std::move(player));
UpdatePadMapping(); // sync pad mappings with everyone
UpdateWiimoteMapping();
@ -491,7 +491,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
{
if (mapping == pid && pid != 1)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
m_is_running = false;
sf::Packet spac;
@ -516,7 +516,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
enet_peer_disconnect(player.socket, 0);
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
auto it = m_players.find(player.pid);
if (it != m_players.end())
m_players.erase(it);
@ -597,7 +597,7 @@ void NetPlayServer::UpdateWiimoteMapping()
// called from ---GUI--- thread and ---NETPLAY--- thread
void NetPlayServer::AdjustPadBufferSize(unsigned int size)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
m_target_buffer_size = size;
@ -615,7 +615,7 @@ void NetPlayServer::AdjustPadBufferSize(unsigned int size)
void NetPlayServer::SetHostInputAuthority(const bool enable)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
m_host_input_authority = enable;
@ -634,7 +634,7 @@ void NetPlayServer::SetHostInputAuthority(const bool enable)
void NetPlayServer::SendAsync(sf::Packet&& packet, const PlayerId pid, const u8 channel_id)
{
{
std::lock_guard<std::recursive_mutex> lkq(m_crit.async_queue_write);
std::lock_guard lkq(m_crit.async_queue_write);
m_async_queue.Push(AsyncQueueEntry{std::move(packet), pid, TargetMode::Only, channel_id});
}
ENetUtil::WakeupThread(m_server);
@ -644,7 +644,7 @@ void NetPlayServer::SendAsyncToClients(sf::Packet&& packet, const PlayerId skip_
const u8 channel_id)
{
{
std::lock_guard<std::recursive_mutex> lkq(m_crit.async_queue_write);
std::lock_guard lkq(m_crit.async_queue_write);
m_async_queue.Push(
AsyncQueueEntry{std::move(packet), skip_pid, TargetMode::AllExcept, channel_id});
}
@ -654,7 +654,7 @@ void NetPlayServer::SendAsyncToClients(sf::Packet&& packet, const PlayerId skip_
void NetPlayServer::SendChunked(sf::Packet&& packet, const PlayerId pid, const std::string& title)
{
{
std::lock_guard<std::recursive_mutex> lkq(m_crit.chunked_data_queue_write);
std::lock_guard lkq(m_crit.chunked_data_queue_write);
m_chunked_data_queue.Push(
ChunkedDataQueueEntry{std::move(packet), pid, TargetMode::Only, title});
}
@ -665,7 +665,7 @@ void NetPlayServer::SendChunkedToClients(sf::Packet&& packet, const PlayerId ski
const std::string& title)
{
{
std::lock_guard<std::recursive_mutex> lkq(m_crit.chunked_data_queue_write);
std::lock_guard lkq(m_crit.chunked_data_queue_write);
m_chunked_data_queue.Push(
ChunkedDataQueueEntry{std::move(packet), skip_pid, TargetMode::AllExcept, title});
}
@ -919,7 +919,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
sf::Packet spac;
spac << (MessageId)NP_MSG_STOP_GAME;
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard lkp(m_crit.players);
SendToClients(spac);
}
break;
@ -1170,7 +1170,7 @@ void NetPlayServer::SendChatMessage(const std::string& msg)
bool NetPlayServer::ChangeGame(const SyncIdentifier& sync_identifier,
const std::string& netplay_name)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
m_selected_game_identifier = sync_identifier;
m_selected_game_name = netplay_name;
@ -1264,7 +1264,7 @@ bool NetPlayServer::StartGame()
{
m_timebase_by_frame.clear();
m_desync_detected = false;
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
std::lock_guard lkg(m_crit.game);
m_current_game = Common::Timer::GetTimeMs();
// no change, just update with clients