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/client/clientlauncher.cpp | 6 +++--- src/client/tile.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/client') diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index bad5c384c..60eb21674 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -651,14 +651,14 @@ void ClientLauncher::speed_tests() infostream << "Around 5000/ms should do well here." << std::endl; TimeTaker timer("Testing mutex speed"); - JMutex m; + Mutex m; u32 n = 0; u32 i = 0; do { n += 10000; for (; i < n; i++) { - m.Lock(); - m.Unlock(); + m.lock(); + m.unlock(); } } // Do at least 10ms diff --git a/src/client/tile.cpp b/src/client/tile.cpp index a28b40c65..1f1e9d38c 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -414,7 +414,7 @@ private: // Maps a texture name to an index in the former. std::map m_name_to_id; // The two former containers are behind this mutex - JMutex m_textureinfo_cache_mutex; + Mutex m_textureinfo_cache_mutex; // Queued texture fetches (to be processed by the main thread) RequestQueue m_get_texture_queue; @@ -490,7 +490,7 @@ u32 TextureSource::getTextureId(const std::string &name) /* See if texture already exists */ - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); std::map::iterator n; n = m_name_to_id.find(name); if (n != m_name_to_id.end()) @@ -593,7 +593,7 @@ u32 TextureSource::generateTexture(const std::string &name) /* See if texture already exists */ - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); std::map::iterator n; n = m_name_to_id.find(name); if (n != m_name_to_id.end()) { @@ -631,7 +631,7 @@ u32 TextureSource::generateTexture(const std::string &name) Add texture to caches (add NULL textures too) */ - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); u32 id = m_textureinfo_cache.size(); TextureInfo ti(name, tex); @@ -643,7 +643,7 @@ u32 TextureSource::generateTexture(const std::string &name) std::string TextureSource::getTextureName(u32 id) { - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); if (id >= m_textureinfo_cache.size()) { @@ -658,7 +658,7 @@ std::string TextureSource::getTextureName(u32 id) video::ITexture* TextureSource::getTexture(u32 id) { - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); if (id >= m_textureinfo_cache.size()) return NULL; @@ -712,7 +712,7 @@ void TextureSource::insertSourceImage(const std::string &name, video::IImage *im void TextureSource::rebuildImagesAndTextures() { - JMutexAutoLock lock(m_textureinfo_cache_mutex); + MutexAutoLock lock(m_textureinfo_cache_mutex); video::IVideoDriver* driver = m_device->getVideoDriver(); sanity_check(driver); -- cgit v1.2.3