1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +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:
ShadowNinja 2015-04-07 06:13:12 -04:00
parent 6a1047d8c1
commit e4bff8be94
77 changed files with 1594 additions and 2046 deletions

View file

@ -20,8 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "minimap.h"
#include <math.h>
#include "logoutputbuffer.h"
#include "jthread/jmutexautolock.h"
#include "jthread/jsemaphore.h"
#include "threading/mutex_auto_lock.h"
#include "threading/semaphore.h"
#include "clientmap.h"
#include "settings.h"
#include "nodedef.h"
@ -52,7 +52,7 @@ MinimapUpdateThread::~MinimapUpdateThread()
bool MinimapUpdateThread::pushBlockUpdate(v3s16 pos, MinimapMapblock *data)
{
JMutexAutoLock lock(m_queue_mutex);
MutexAutoLock lock(m_queue_mutex);
// Find if block is already in queue.
// If it is, update the data and quit.
@ -78,7 +78,7 @@ bool MinimapUpdateThread::pushBlockUpdate(v3s16 pos, MinimapMapblock *data)
bool MinimapUpdateThread::popBlockUpdate(QueuedMinimapUpdate *update)
{
JMutexAutoLock lock(m_queue_mutex);
MutexAutoLock lock(m_queue_mutex);
if (m_update_queue.empty())
return false;
@ -256,13 +256,13 @@ Mapper::Mapper(IrrlichtDevice *device, Client *client)
// Initialize and start thread
m_minimap_update_thread = new MinimapUpdateThread();
m_minimap_update_thread->data = data;
m_minimap_update_thread->Start();
m_minimap_update_thread->start();
}
Mapper::~Mapper()
{
m_minimap_update_thread->Stop();
m_minimap_update_thread->Wait();
m_minimap_update_thread->stop();
m_minimap_update_thread->wait();
m_meshbuffer->drop();
@ -290,7 +290,7 @@ MinimapMode Mapper::getMinimapMode()
void Mapper::toggleMinimapShape()
{
JMutexAutoLock lock(m_mutex);
MutexAutoLock lock(m_mutex);
data->minimap_shape_round = !data->minimap_shape_round;
g_settings->setBool("minimap_shape_round", data->minimap_shape_round);
@ -312,7 +312,7 @@ void Mapper::setMinimapMode(MinimapMode mode)
if (mode >= MINIMAP_MODE_COUNT)
return;
JMutexAutoLock lock(m_mutex);
MutexAutoLock lock(m_mutex);
data->is_radar = modedefs[mode].is_radar;
data->scan_height = modedefs[mode].scan_height;
@ -327,7 +327,7 @@ void Mapper::setPos(v3s16 pos)
bool do_update = false;
{
JMutexAutoLock lock(m_mutex);
MutexAutoLock lock(m_mutex);
if (pos != data->old_pos) {
data->old_pos = data->pos;