Replace remaining Boost mutexs with std::mutex
CHANGED: Replaced all MUTEX types with std::mutex Replaced all MUTLOCK types with std::lock_guard
This commit is contained in:
parent
38f54b4372
commit
9e6e9d0910
|
@ -34,6 +34,7 @@
|
|||
#include <macros.h>
|
||||
#include <base_units.h>
|
||||
#include <reporter.h>
|
||||
#include <mutex>
|
||||
|
||||
#include <wx/process.h>
|
||||
#include <wx/config.h>
|
||||
|
@ -454,14 +455,13 @@ wxString KIwxExpandEnvVars(const wxString& str)
|
|||
}
|
||||
|
||||
|
||||
#include <ki_mutex.h>
|
||||
const wxString ExpandEnvVarSubstitutions( const wxString& aString )
|
||||
{
|
||||
// wxGetenv( wchar_t* ) is not re-entrant on linux.
|
||||
// Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(),
|
||||
static MUTEX getenv_mutex;
|
||||
static std::mutex getenv_mutex;
|
||||
|
||||
MUTLOCK lock( getenv_mutex );
|
||||
std::lock_guard<std::mutex> lock( getenv_mutex );
|
||||
|
||||
// We reserve the right to do this another way, by providing our own member function.
|
||||
return KIwxExpandEnvVars( aString );
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// conflicts for some defines, at least on Windows
|
||||
#include <kicad_curl/kicad_curl.h>
|
||||
|
||||
#include <ki_mutex.h> // MUTEX and MUTLOCK
|
||||
#include <mutex>
|
||||
#include <ki_exception.h> // THROW_IO_ERROR
|
||||
|
||||
|
||||
|
@ -37,14 +37,14 @@
|
|||
// client (API) header file.
|
||||
static volatile bool s_initialized;
|
||||
|
||||
static MUTEX s_lock; // for s_initialized
|
||||
static std::mutex s_lock; // for s_initialized
|
||||
|
||||
// Assume that on these platforms libcurl uses OpenSSL
|
||||
#if defined(__linux__) || defined(__MINGW32__)
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
static MUTEX* s_crypto_locks;
|
||||
static std::mutex* s_crypto_locks;
|
||||
|
||||
/*
|
||||
* From OpenSSL v1.1.0, the CRYPTO_set_locking_callback macro is a no-op.
|
||||
|
@ -83,7 +83,7 @@ static void lock_callback( int mode, int type, const char* file, int line )
|
|||
|
||||
static void init_locks()
|
||||
{
|
||||
s_crypto_locks = new MUTEX[ CRYPTO_num_locks() ];
|
||||
s_crypto_locks = new std::mutex[ CRYPTO_num_locks() ];
|
||||
|
||||
// From http://linux.die.net/man/3/crypto_set_id_callback:
|
||||
|
||||
|
@ -154,7 +154,7 @@ void KICAD_CURL::Init()
|
|||
// will not need to lock.
|
||||
if( !s_initialized )
|
||||
{
|
||||
MUTLOCK lock( s_lock );
|
||||
std::lock_guard<std::mutex> lock( s_lock );
|
||||
|
||||
if( !s_initialized )
|
||||
{
|
||||
|
@ -177,22 +177,22 @@ void KICAD_CURL::Cleanup()
|
|||
{
|
||||
/*
|
||||
|
||||
Calling MUTLOCK() from a static destructor will typically be bad, since the
|
||||
Calling lock_guard() from a static destructor will typically be bad, since the
|
||||
s_lock may already have been statically destroyed itself leading to a boost
|
||||
exception. (Remember C++ does not provide certain sequencing of static
|
||||
destructor invocation.)
|
||||
|
||||
To prevent this we test s_initialized twice, which ensures that the MUTLOCK
|
||||
To prevent this we test s_initialized twice, which ensures that the lock_guard
|
||||
is only instantiated on the first call, which should be from
|
||||
PGM_BASE::destroy() which is first called earlier than static destruction.
|
||||
Then when called again from the actual PGM_BASE::~PGM_BASE() function,
|
||||
MUTLOCK will not be instantiated because s_initialized will be false.
|
||||
lock_guard will not be instantiated because s_initialized will be false.
|
||||
|
||||
*/
|
||||
|
||||
if( s_initialized )
|
||||
{
|
||||
MUTLOCK lock( s_lock );
|
||||
std::lock_guard<std::mutex> lock( s_lock );
|
||||
|
||||
if( s_initialized )
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define GL_CONTEXT_MANAGER_H
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
#include <ki_mutex.h>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
class GL_CONTEXT_MANAGER
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
wxGLContext* m_glCtx;
|
||||
|
||||
///> Lock to prevent unexpected GL context switching.
|
||||
MUTEX m_glCtxMutex;
|
||||
std::mutex m_glCtxMutex;
|
||||
|
||||
// Singleton
|
||||
GL_CONTEXT_MANAGER();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <math/box2.h>
|
||||
#include <class_module.h>
|
||||
#include <class_board.h>
|
||||
#include <ki_mutex.h>
|
||||
#include <mutex>
|
||||
#include <draw_frame.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <utility>
|
||||
|
@ -51,7 +51,7 @@ class FP_THREAD_IFACE
|
|||
/// Retrieve a cache entry by LIB_ID
|
||||
OPT<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
auto it = m_cachedFootprints.find( aFPID );
|
||||
|
||||
if( it != m_cachedFootprints.end() )
|
||||
|
@ -66,7 +66,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
CACHE_ENTRY AddToQueue( LIB_ID const & aEntry )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
|
||||
CACHE_ENTRY ent = { aEntry, NULL, FPS_LOADING };
|
||||
m_cachedFootprints[aEntry] = ent;
|
||||
|
@ -78,7 +78,7 @@ class FP_THREAD_IFACE
|
|||
/// Pop an entry from the queue, or empty option if none is available.
|
||||
OPT<CACHE_ENTRY> PopFromQueue()
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
|
||||
if( m_loaderQueue.empty() )
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ class FP_THREAD_IFACE
|
|||
/// Add an entry to the cache.
|
||||
void AddToCache( CACHE_ENTRY const & aEntry )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
m_cachedFootprints[aEntry.fpid] = aEntry;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
void SetCurrentFootprint( LIB_ID aFp )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
m_current_fp = std::move( aFp );
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
LIB_ID GetCurrentFootprint()
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
return m_current_fp;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
void SetPanel( FOOTPRINT_PREVIEW_PANEL* aPanel )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
m_panel = aPanel;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
FOOTPRINT_PREVIEW_PANEL* GetPanel()
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
return m_panel;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
bool QueueEvent( wxEvent const& aEvent )
|
||||
{
|
||||
MUTLOCK lock( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
|
||||
if( m_panel )
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
FP_LIB_TABLE* GetTable()
|
||||
{
|
||||
MUTLOCK locK( m_lock );
|
||||
std::lock_guard<std::mutex> locK( m_lock );
|
||||
return m_panel ? m_panel->Prj().PcbFootprintLibs() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class FP_THREAD_IFACE
|
|||
std::map<LIB_ID, CACHE_ENTRY> m_cachedFootprints;
|
||||
LIB_ID m_current_fp;
|
||||
FOOTPRINT_PREVIEW_PANEL* m_panel = nullptr;
|
||||
MUTEX m_lock;
|
||||
std::mutex m_lock;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue