Better thread safety for zone boundingbox caches.
This commit is contained in:
parent
adbbceacda
commit
97d4df4154
|
@ -1151,7 +1151,6 @@ public:
|
|||
std::unordered_map< wxString, LSET > m_LayerExpressionCache;
|
||||
std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
|
||||
std::unique_ptr<DRC_RTREE> m_CopperItemRTreeCache;
|
||||
|
||||
mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
|
||||
|
||||
// ------------ DRC caches -------------
|
||||
|
|
|
@ -308,16 +308,19 @@ bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer ) const
|
|||
|
||||
const BOX2I ZONE::GetBoundingBox() const
|
||||
{
|
||||
if( const BOARD* parent = GetBoard() )
|
||||
if( const BOARD* board = GetBoard() )
|
||||
{
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = parent->m_ZoneBBoxCache;
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||
auto cacheIter = cache.find( this );
|
||||
|
||||
if( cacheIter != cache.end() )
|
||||
return cacheIter->second;
|
||||
|
||||
BOX2I bbox = m_Poly->BBox();
|
||||
|
||||
std::unique_lock<std::mutex> cacheLock( const_cast<BOARD*>( board )->m_CachesMutex );
|
||||
cache[ this ] = bbox;
|
||||
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
@ -327,13 +330,17 @@ const BOX2I ZONE::GetBoundingBox() const
|
|||
|
||||
void ZONE::CacheBoundingBox()
|
||||
{
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = GetBoard()->m_ZoneBBoxCache;
|
||||
BOARD* board = GetBoard();
|
||||
std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
|
||||
|
||||
auto cacheIter = cache.find( this );
|
||||
|
||||
if( cacheIter == cache.end() )
|
||||
{
|
||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||
cache[ this ] = m_Poly->BBox();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ZONE::GetThermalReliefGap( PAD* aPad, wxString* aSource ) const
|
||||
|
|
Loading…
Reference in New Issue