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
|
@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <IFileSystem.h>
|
||||
#include "jthread/jmutexautolock.h"
|
||||
#include "threading/mutex_auto_lock.h"
|
||||
#include "util/auth.h"
|
||||
#include "util/directiontables.h"
|
||||
#include "util/pointedthing.h"
|
||||
|
@ -82,7 +82,7 @@ MeshUpdateQueue::MeshUpdateQueue()
|
|||
|
||||
MeshUpdateQueue::~MeshUpdateQueue()
|
||||
{
|
||||
JMutexAutoLock lock(m_mutex);
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
for(std::vector<QueuedMeshUpdate*>::iterator
|
||||
i = m_queue.begin();
|
||||
|
@ -102,7 +102,7 @@ void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_se
|
|||
|
||||
assert(data); // pre-condition
|
||||
|
||||
JMutexAutoLock lock(m_mutex);
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
if(urgent)
|
||||
m_urgents.insert(p);
|
||||
|
@ -141,7 +141,7 @@ void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_se
|
|||
// Returns NULL if queue is empty
|
||||
QueuedMeshUpdate *MeshUpdateQueue::pop()
|
||||
{
|
||||
JMutexAutoLock lock(m_mutex);
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
bool must_be_urgent = !m_urgents.empty();
|
||||
for(std::vector<QueuedMeshUpdate*>::iterator
|
||||
|
@ -269,7 +269,7 @@ Client::Client(
|
|||
void Client::Stop()
|
||||
{
|
||||
//request all client managed threads to stop
|
||||
m_mesh_update_thread.Stop();
|
||||
m_mesh_update_thread.stop();
|
||||
// Save local server map
|
||||
if (m_localdb) {
|
||||
infostream << "Local map saving ended." << std::endl;
|
||||
|
@ -280,7 +280,7 @@ void Client::Stop()
|
|||
bool Client::isShutdown()
|
||||
{
|
||||
|
||||
if (!m_mesh_update_thread.IsRunning()) return true;
|
||||
if (!m_mesh_update_thread.isRunning()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ Client::~Client()
|
|||
{
|
||||
m_con.Disconnect();
|
||||
|
||||
m_mesh_update_thread.Stop();
|
||||
m_mesh_update_thread.Wait();
|
||||
m_mesh_update_thread.stop();
|
||||
m_mesh_update_thread.wait();
|
||||
while (!m_mesh_update_thread.m_queue_out.empty()) {
|
||||
MeshUpdateResult r = m_mesh_update_thread.m_queue_out.pop_frontNoEx();
|
||||
delete r.mesh;
|
||||
|
@ -1270,7 +1270,7 @@ void Client::sendPlayerPos()
|
|||
|
||||
u16 our_peer_id;
|
||||
{
|
||||
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||
//MutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||
our_peer_id = m_con.GetPeerID();
|
||||
}
|
||||
|
||||
|
@ -1794,7 +1794,7 @@ void Client::afterContentReceived(IrrlichtDevice *device)
|
|||
|
||||
// Start mesh update thread after setting up content definitions
|
||||
infostream<<"- Starting mesh update thread"<<std::endl;
|
||||
m_mesh_update_thread.Start();
|
||||
m_mesh_update_thread.start();
|
||||
|
||||
m_state = LC_Ready;
|
||||
sendReady();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue