KiCad PCB EDA Suite
FP_THREAD_IFACE Class Reference

Threadsafe interface class between loader thread and panel class. More...

Public Member Functions

boost::optional< CACHE_ENTRYGetFromCache (LIB_ID const &aFPID)
 Retrieve a cache entry by LIB_ID. More...
 
CACHE_ENTRY AddToQueue (LIB_ID const &aEntry)
 Push an entry to the loading queue and a placeholder to the cache; return the placeholder. More...
 
boost::optional< CACHE_ENTRYPopFromQueue ()
 Pop an entry from the queue, or empty option if none is available. More...
 
void AddToCache (CACHE_ENTRY const &aEntry)
 Add an entry to the cache. More...
 
void SetCurrentFootprint (LIB_ID aFp)
 Threadsafe accessor to set the current footprint. More...
 
LIB_ID GetCurrentFootprint ()
 Threadsafe accessor to get the current footprint. More...
 

Private Types

using CACHE_ENTRY = FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY
 

Private Attributes

std::deque< CACHE_ENTRYm_loaderQueue
 
std::map< LIB_ID, CACHE_ENTRYm_cachedFootprints
 
LIB_ID m_current_fp
 
MUTEX m_lock
 

Detailed Description

Threadsafe interface class between loader thread and panel class.

Definition at line 43 of file footprint_preview_panel.cpp.

Member Typedef Documentation

Member Function Documentation

void FP_THREAD_IFACE::AddToCache ( CACHE_ENTRY const &  aEntry)
inline

Add an entry to the cache.

Definition at line 93 of file footprint_preview_panel.cpp.

References FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY::fpid, m_cachedFootprints, and m_lock.

94  {
95  MUTLOCK lock( m_lock );
96 
97  m_cachedFootprints[aEntry.fpid] = aEntry;
98  }
std::map< LIB_ID, CACHE_ENTRY > m_cachedFootprints
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
CACHE_ENTRY FP_THREAD_IFACE::AddToQueue ( LIB_ID const &  aEntry)
inline

Push an entry to the loading queue and a placeholder to the cache; return the placeholder.

Definition at line 64 of file footprint_preview_panel.cpp.

References FPS_LOADING, m_cachedFootprints, m_loaderQueue, and m_lock.

65  {
66  MUTLOCK lock( m_lock );
67 
68  CACHE_ENTRY ent = { aEntry, NULL, FPS_LOADING };
69  m_cachedFootprints[aEntry] = ent;
70  m_loaderQueue.push_back( ent );
71 
72  return ent;
73  }
FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY CACHE_ENTRY
std::map< LIB_ID, CACHE_ENTRY > m_cachedFootprints
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
std::deque< CACHE_ENTRY > m_loaderQueue
LIB_ID FP_THREAD_IFACE::GetCurrentFootprint ( )
inline

Threadsafe accessor to get the current footprint.

Definition at line 112 of file footprint_preview_panel.cpp.

References m_current_fp, and m_lock.

113  {
114  MUTLOCK lock( m_lock );
115  return m_current_fp;
116  }
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
boost::optional<CACHE_ENTRY> FP_THREAD_IFACE::GetFromCache ( LIB_ID const &  aFPID)
inline

Retrieve a cache entry by LIB_ID.

Definition at line 49 of file footprint_preview_panel.cpp.

References m_cachedFootprints, and m_lock.

50  {
51  MUTLOCK lock( m_lock );
52  auto it = m_cachedFootprints.find( aFPID );
53 
54  if( it != m_cachedFootprints.end() )
55  return it->second;
56  else
57  return boost::none;
58  }
std::map< LIB_ID, CACHE_ENTRY > m_cachedFootprints
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
boost::optional<CACHE_ENTRY> FP_THREAD_IFACE::PopFromQueue ( )
inline

Pop an entry from the queue, or empty option if none is available.

Definition at line 76 of file footprint_preview_panel.cpp.

References m_loaderQueue, and m_lock.

77  {
78  MUTLOCK lock( m_lock );
79 
80  if( m_loaderQueue.empty() )
81  {
82  return boost::none;
83  }
84  else
85  {
86  auto ent = m_loaderQueue.front();
87  m_loaderQueue.pop_front();
88  return ent;
89  }
90  }
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
std::deque< CACHE_ENTRY > m_loaderQueue
void FP_THREAD_IFACE::SetCurrentFootprint ( LIB_ID  aFp)
inline

Threadsafe accessor to set the current footprint.

Definition at line 103 of file footprint_preview_panel.cpp.

References m_current_fp, and m_lock.

104  {
105  MUTLOCK lock( m_lock );
106  m_current_fp = aFp;
107  }
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43

Member Data Documentation

std::map<LIB_ID, CACHE_ENTRY> FP_THREAD_IFACE::m_cachedFootprints
private

Definition at line 120 of file footprint_preview_panel.cpp.

Referenced by AddToCache(), AddToQueue(), and GetFromCache().

LIB_ID FP_THREAD_IFACE::m_current_fp
private

Definition at line 121 of file footprint_preview_panel.cpp.

Referenced by GetCurrentFootprint(), and SetCurrentFootprint().

std::deque<CACHE_ENTRY> FP_THREAD_IFACE::m_loaderQueue
private

Definition at line 119 of file footprint_preview_panel.cpp.

Referenced by AddToQueue(), and PopFromQueue().

MUTEX FP_THREAD_IFACE::m_lock
private

The documentation for this class was generated from the following file: