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 -------------
|
||||
|
|
|
@ -181,7 +181,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
|
|||
m_DRCSeverities[ DRCE_TEXT_THICKNESS ] = RPT_SEVERITY_WARNING;
|
||||
|
||||
m_DRCSeverities[ DRCE_FOOTPRINT_TYPE_MISMATCH ] = RPT_SEVERITY_IGNORE;
|
||||
|
||||
|
||||
m_DRCSeverities[ DRCE_LIB_FOOTPRINT_ISSUES ] = RPT_SEVERITY_WARNING;
|
||||
m_DRCSeverities[ DRCE_LIB_FOOTPRINT_MISMATCH ] = RPT_SEVERITY_WARNING;
|
||||
|
||||
|
|
|
@ -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,12 +330,16 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue