From 89a3d2b45156d350d25f2a5b8909cc36a719c8c0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 30 Sep 2018 12:12:14 -0700 Subject: [PATCH] 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 --- pcbnew/connectivity_data.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcbnew/connectivity_data.cpp b/pcbnew/connectivity_data.cpp index 16575e200a..d27885826c 100644 --- a/pcbnew/connectivity_data.cpp +++ b/pcbnew/connectivity_data.cpp @@ -93,13 +93,14 @@ void CONNECTIVITY_DATA::updateRatsnest() size_t numDirty = std::count_if( m_nets.begin() + 1, m_nets.end(), [] ( RN_NET* aNet ) { return aNet->IsDirty(); } ); + // Start with net 1 as net 0 is reserved for not-connected std::atomic nextNet( 1 ); std::atomic threadsFinished( 0 ); // We don't want to spin up a new thread for fewer than two nets (overhead costs) size_t parallelThreadCount = std::min( std::max( std::thread::hardware_concurrency(), 2 ), - numDirty / 2 ); + ( numDirty + 1 ) / 2 ); for( size_t ii = 0; ii < parallelThreadCount; ++ii ) {