Replace wxCriticalSection with std::mutex

This commit is contained in:
Ian McInerney 2020-01-15 23:42:16 +00:00
parent 208b5695b3
commit 0878fdeab3
3 changed files with 21 additions and 15 deletions

View File

@ -27,6 +27,7 @@
#include <fstream>
#include <iostream>
#include <iterator>
#include <mutex>
#include <sstream>
#include <utility>
@ -60,8 +61,8 @@
#define MASK_3D_CACHE "3D_CACHE"
static wxCriticalSection lock3D_cache;
static wxCriticalSection lock3D_cacheManager;
static std::mutex mutex3D_cache;
static std::mutex mutex3D_cacheManager;
static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB )
@ -225,7 +226,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach
}
// check cache if file is already loaded
wxCriticalSectionLocker lock( lock3D_cache );
std::lock_guard<std::mutex> lock( mutex3D_cache );
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi;
mi = m_CacheMap.find( full3Dpath );
@ -780,7 +782,7 @@ wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName )
S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
{
wxCriticalSectionLocker lock( lock3D_cacheManager );
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
// Get the existing cache from the project
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );

View File

@ -21,9 +21,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <sstream>
#include <fstream>
#include <mutex>
#include <sstream>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
@ -44,7 +45,7 @@
#define MASK_3D_RESOLVER "3D_RESOLVER"
static wxCriticalSection lock_resolver;
static std::mutex mutex_resolver;
static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult );
@ -250,7 +251,7 @@ bool FILENAME_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList )
wxString FILENAME_RESOLVER::ResolvePath( const wxString& aFileName )
{
wxCriticalSectionLocker lock( lock_resolver );
std::lock_guard<std::mutex> lock( mutex_resolver );
if( aFileName.empty() )
return wxEmptyString;
@ -439,7 +440,7 @@ bool FILENAME_RESOLVER::addPath( const SEARCH_PATH& aPath )
if( aPath.m_alias.empty() || aPath.m_pathvar.empty() )
return false;
wxCriticalSectionLocker lock( lock_resolver );
std::lock_guard<std::mutex> lock( mutex_resolver );
SEARCH_PATH tpath = aPath;
@ -759,7 +760,8 @@ wxString FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName )
if( m_Paths.empty() )
createPathList();
wxCriticalSectionLocker lock( lock_resolver );
std::lock_guard<std::mutex> lock( mutex_resolver );
std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin();
size_t idx;

View File

@ -21,12 +21,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <mutex>
#include <sstream>
#include <wx/fileconf.h>
#include <wx/filename.h>
#include <wx/log.h>
@ -48,7 +49,7 @@
#define MASK_3D_RESOLVER "3D_RESOLVER"
static wxCriticalSection lock3D_resolver;
static std::mutex mutex3D_resolver;
static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult );
@ -326,7 +327,7 @@ bool S3D_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList )
wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
{
wxCriticalSectionLocker lock( lock3D_resolver );
std::lock_guard<std::mutex> lock( mutex3D_resolver );
if( aFileName.empty() )
return wxEmptyString;
@ -524,7 +525,7 @@ bool S3D_RESOLVER::addPath( const SEARCH_PATH& aPath )
if( aPath.m_alias.empty() || aPath.m_pathvar.empty() )
return false;
wxCriticalSectionLocker lock( lock3D_resolver );
std::lock_guard<std::mutex> lock( mutex3D_resolver );
SEARCH_PATH tpath = aPath;
@ -895,7 +896,8 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName )
if( m_Paths.empty() )
createPathList();
wxCriticalSectionLocker lock( lock3D_resolver );
std::lock_guard<std::mutex> lock( mutex3D_resolver );
std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin();
std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end();
size_t idx;