Use ki_mutex.h in FOOTPRINT_PREVIEW_PANEL

This commit is contained in:
Chris Pavlina 2017-03-11 08:22:08 -05:00
parent 23a23d3c63
commit 5af825e21c
1 changed files with 8 additions and 9 deletions

View File

@ -29,6 +29,7 @@
#include <math/box2.h> #include <math/box2.h>
#include <class_module.h> #include <class_module.h>
#include <class_board.h> #include <class_board.h>
#include <ki_mutex.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <make_unique.h> #include <make_unique.h>
@ -36,8 +37,6 @@
#include <wx/stattext.h> #include <wx/stattext.h>
/** /**
* Threadsafe interface class between loader thread and panel class. * Threadsafe interface class between loader thread and panel class.
*/ */
@ -49,7 +48,7 @@ class FP_THREAD_IFACE
/// Retrieve a cache entry by LIB_ID /// Retrieve a cache entry by LIB_ID
boost::optional<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID ) boost::optional<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
auto it = m_cachedFootprints.find( aFPID ); auto it = m_cachedFootprints.find( aFPID );
if( it != m_cachedFootprints.end() ) if( it != m_cachedFootprints.end() )
@ -64,7 +63,7 @@ class FP_THREAD_IFACE
*/ */
CACHE_ENTRY AddToQueue( LIB_ID const & aEntry ) CACHE_ENTRY AddToQueue( LIB_ID const & aEntry )
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
CACHE_ENTRY ent = { aEntry, NULL, FPS_LOADING }; CACHE_ENTRY ent = { aEntry, NULL, FPS_LOADING };
m_cachedFootprints[aEntry] = ent; m_cachedFootprints[aEntry] = ent;
@ -76,7 +75,7 @@ class FP_THREAD_IFACE
/// Pop an entry from the queue, or empty option if none is available. /// Pop an entry from the queue, or empty option if none is available.
boost::optional<CACHE_ENTRY> PopFromQueue() boost::optional<CACHE_ENTRY> PopFromQueue()
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
if( m_loaderQueue.empty() ) if( m_loaderQueue.empty() )
{ {
@ -93,7 +92,7 @@ class FP_THREAD_IFACE
/// Add an entry to the cache. /// Add an entry to the cache.
void AddToCache( CACHE_ENTRY const & aEntry ) void AddToCache( CACHE_ENTRY const & aEntry )
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
m_cachedFootprints[aEntry.fpid] = aEntry; m_cachedFootprints[aEntry.fpid] = aEntry;
} }
@ -103,7 +102,7 @@ class FP_THREAD_IFACE
*/ */
void SetCurrentFootprint( LIB_ID aFp ) void SetCurrentFootprint( LIB_ID aFp )
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
m_current_fp = aFp; m_current_fp = aFp;
} }
@ -112,7 +111,7 @@ class FP_THREAD_IFACE
*/ */
LIB_ID GetCurrentFootprint() LIB_ID GetCurrentFootprint()
{ {
wxMutexLocker lock( m_lock ); MUTLOCK lock( m_lock );
return m_current_fp; return m_current_fp;
} }
@ -120,7 +119,7 @@ class FP_THREAD_IFACE
std::deque<CACHE_ENTRY> m_loaderQueue; std::deque<CACHE_ENTRY> m_loaderQueue;
std::map<LIB_ID, CACHE_ENTRY> m_cachedFootprints; std::map<LIB_ID, CACHE_ENTRY> m_cachedFootprints;
LIB_ID m_current_fp; LIB_ID m_current_fp;
wxMutex m_lock; MUTEX m_lock;
}; };