aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-04-07 06:13:12 -0400
committerShadowNinja <shadowninja@minetest.net>2015-08-23 22:04:06 -0400
commite4bff8be94c0db4f94e63ad448d0eeb869ccdbbd (patch)
tree7935586e79da5c8c7144e345a8c0fc1cda53beed /src/client
parent6a1047d8c116f793890b63427d53f04ceca95d54 (diff)
downloadminetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.gz
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.bz2
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.zip
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.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/clientlauncher.cpp6
-rw-r--r--src/client/tile.cpp14
2 files changed, 10 insertions, 10 deletions
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<std::string, u32> 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<std::string, u32, u8, u8> 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<std::string, u32>::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<std::string, u32>::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);