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
commit e527b69d54
3 changed files with 36 additions and 36 deletions

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