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
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue