Skip to content

Commit

Permalink
Use xrCore's locks instead of std::mutex
Browse files Browse the repository at this point in the history
I suggest that in the future Lock should become a wrapper of std::mutex
and the current Lock should be renamed to RecursiveLock.
  • Loading branch information
Zegeri authored and eagleivg committed Nov 8, 2018
1 parent 1786320 commit b1799b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/xrUICore/XML/UITextureMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "uiabstract.h"
#include "xrUIXmlParser.h"
#include "Include/xrRender/UIShader.h"
#include "xrCore/Threading/Lock.hpp"
#include "xrCore/Threading/ScopeLock.hpp"
#include <iostream>
#include <mutex>

xr_map<shared_str, TEX_INFO> CUITextureMaster::m_textures;
xr_map<sh_pair, ui_shader> CUITextureMaster::m_shaders;
Expand Down Expand Up @@ -55,10 +56,8 @@ void CUITextureMaster::ParseShTexInfo(pcstr path, pcstr xml_file)
/* avo: fix issue when values were not updated (silently skipped) when same key is encountered more than once. This is how std::map is designed.
/* Also used more efficient C++11 std::map::emplace method instead of outdated std::pair::make_pair */
/* XXX: avo: note that xxx.insert(mk_pair(v1,v2)) pattern is used extensively throughout solution so there is a good potential for other bug fixes/improvements */
#ifdef LINUX
static std::mutex new_texture_mutex;
std::scoped_lock new_texture_lock (new_texture_mutex);
#endif
static Lock new_texture_lock;
ScopeLock new_texture_guard(&new_texture_lock);
if (m_textures.find(id) == m_textures.end())
m_textures.emplace(id, info);
else
Expand Down

0 comments on commit b1799b8

Please sign in to comment.