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/minimap.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/minimap.cpp') diff --git a/src/minimap.cpp b/src/minimap.cpp index d1fb3867d..7eb7247ca 100644 --- a/src/minimap.cpp +++ b/src/minimap.cpp @@ -20,8 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "minimap.h" #include #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; -- cgit v1.2.3