pcbnew: Force at least one connectivity thread

We want to keep at most 1 thread per 2 connectivity updates but we need
to force that floor to be at least 1 for when there is only 1
connectivity update.

Fixes: lp:1795245
* https://bugs.launchpad.net/kicad/+bug/1795245

(cherry picked from commit 89a3d2b451)
This commit is contained in:
Seth Hillbrand 2018-09-30 12:12:14 -07:00
parent 13a41f11eb
commit 9837d1624f
1 changed files with 2 additions and 1 deletions

View File

@ -93,13 +93,14 @@ void CONNECTIVITY_DATA::updateRatsnest()
size_t numDirty = std::count_if( m_nets.begin() + 1, m_nets.end(), [] ( RN_NET* aNet ) size_t numDirty = std::count_if( m_nets.begin() + 1, m_nets.end(), [] ( RN_NET* aNet )
{ return aNet->IsDirty(); } ); { return aNet->IsDirty(); } );
// Start with net 1 as net 0 is reserved for not-connected
std::atomic<size_t> nextNet( 1 ); std::atomic<size_t> nextNet( 1 );
std::atomic<size_t> threadsFinished( 0 ); std::atomic<size_t> threadsFinished( 0 );
// We don't want to spin up a new thread for fewer than two nets (overhead costs) // We don't want to spin up a new thread for fewer than two nets (overhead costs)
size_t parallelThreadCount = std::min<size_t>( size_t parallelThreadCount = std::min<size_t>(
std::max<size_t>( std::thread::hardware_concurrency(), 2 ), std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
numDirty / 2 ); ( numDirty + 1 ) / 2 );
for( size_t ii = 0; ii < parallelThreadCount; ++ii ) for( size_t ii = 0; ii < parallelThreadCount; ++ii )
{ {