mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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<type>`. * 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.
This commit is contained in:
parent
6a1047d8c1
commit
e4bff8be94
77 changed files with 1594 additions and 2046 deletions
|
@ -593,7 +593,7 @@ ClientInterface::~ClientInterface()
|
|||
Delete clients
|
||||
*/
|
||||
{
|
||||
JMutexAutoLock clientslock(m_clients_mutex);
|
||||
MutexAutoLock clientslock(m_clients_mutex);
|
||||
|
||||
for(std::map<u16, RemoteClient*>::iterator
|
||||
i = m_clients.begin();
|
||||
|
@ -609,7 +609,7 @@ ClientInterface::~ClientInterface()
|
|||
std::vector<u16> ClientInterface::getClientIDs(ClientState min_state)
|
||||
{
|
||||
std::vector<u16> reply;
|
||||
JMutexAutoLock clientslock(m_clients_mutex);
|
||||
MutexAutoLock clientslock(m_clients_mutex);
|
||||
|
||||
for(std::map<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::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<u16, RemoteClient*>::iterator n;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue