From e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Tue, 7 Apr 2015 06:13:12 -0400 Subject: Clean up threading * Rename everything. * Strip J prefix. * Change UpperCamelCase functions to lowerCamelCase. * Remove global (!) semaphore count mutex on OSX. * Remove semaphore count getter (unused, unsafe, depended on internal API functions on Windows, and used a hack on OSX). * Add `Atomic`. * Make `Thread` handle thread names. * Add support for C++11 multi-threading. * Combine pthread and win32 sources. * Remove `ThreadStarted` (unused, unneeded). * Move some includes from the headers to the sources. * Move all of `Event` into its header (allows inlining with no new includes). * Make `Event` use `Semaphore` (except on Windows). * Move some porting functions into `Thread`. * Integrate logging with `Thread`. * Add threading test. --- src/clientiface.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/clientiface.cpp') diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 3330e0af9..d4efe60ef 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -593,7 +593,7 @@ ClientInterface::~ClientInterface() Delete clients */ { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); for(std::map::iterator i = m_clients.begin(); @@ -609,7 +609,7 @@ ClientInterface::~ClientInterface() std::vector ClientInterface::getClientIDs(ClientState min_state) { std::vector reply; - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); for(std::map::iterator i = m_clients.begin(); @@ -660,7 +660,7 @@ void ClientInterface::UpdatePlayerList() infostream << "* " << player->getName() << "\t"; { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); RemoteClient* client = lockedGetClientNoEx(*i); if(client != NULL) client->PrintInfo(infostream); @@ -680,7 +680,7 @@ void ClientInterface::send(u16 peer_id, u8 channelnum, void ClientInterface::sendToAll(u16 channelnum, NetworkPacket* pkt, bool reliable) { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); for(std::map::iterator i = m_clients.begin(); i != m_clients.end(); ++i) { @@ -694,7 +694,7 @@ void ClientInterface::sendToAll(u16 channelnum, RemoteClient* ClientInterface::getClientNoEx(u16 peer_id, ClientState state_min) { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); std::map::iterator n; n = m_clients.find(peer_id); // The client may not exist; clients are immediately removed if their @@ -725,7 +725,7 @@ RemoteClient* ClientInterface::lockedGetClientNoEx(u16 peer_id, ClientState stat ClientState ClientInterface::getClientState(u16 peer_id) { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); std::map::iterator n; n = m_clients.find(peer_id); // The client may not exist; clients are immediately removed if their @@ -738,7 +738,7 @@ ClientState ClientInterface::getClientState(u16 peer_id) void ClientInterface::setPlayerName(u16 peer_id,std::string name) { - JMutexAutoLock clientslock(m_clients_mutex); + MutexAutoLock clientslock(m_clients_mutex); std::map::iterator n; n = m_clients.find(peer_id); // The client may not exist; clients are immediately removed if their @@ -749,7 +749,7 @@ void ClientInterface::setPlayerName(u16 peer_id,std::string name) void ClientInterface::DeleteClient(u16 peer_id) { - JMutexAutoLock conlock(m_clients_mutex); + MutexAutoLock conlock(m_clients_mutex); // Error check std::map::iterator n; @@ -784,7 +784,7 @@ void ClientInterface::DeleteClient(u16 peer_id) void ClientInterface::CreateClient(u16 peer_id) { - JMutexAutoLock conlock(m_clients_mutex); + MutexAutoLock conlock(m_clients_mutex); // Error check std::map::iterator n; @@ -801,7 +801,7 @@ void ClientInterface::CreateClient(u16 peer_id) void ClientInterface::event(u16 peer_id, ClientStateEvent event) { { - JMutexAutoLock clientlock(m_clients_mutex); + MutexAutoLock clientlock(m_clients_mutex); // Error check std::map::iterator n; @@ -823,7 +823,7 @@ void ClientInterface::event(u16 peer_id, ClientStateEvent event) u16 ClientInterface::getProtocolVersion(u16 peer_id) { - JMutexAutoLock conlock(m_clients_mutex); + MutexAutoLock conlock(m_clients_mutex); // Error check std::map::iterator n; @@ -838,7 +838,7 @@ u16 ClientInterface::getProtocolVersion(u16 peer_id) void ClientInterface::setClientVersion(u16 peer_id, u8 major, u8 minor, u8 patch, std::string full) { - JMutexAutoLock conlock(m_clients_mutex); + MutexAutoLock conlock(m_clients_mutex); // Error check std::map::iterator n; -- cgit v1.2.3