Avoid Yields when the results are ready

We always need to check for calculation results before yielding the
system otherwise we will delay outcomes

Fixes https://gitlab.com/kicad/code/kicad/issues/12228
This commit is contained in:
Seth Hillbrand 2022-09-14 13:28:46 -07:00
parent bd8b737c44
commit 26a1114e3c
9 changed files with 48 additions and 57 deletions

View File

@ -653,18 +653,17 @@ void BOARD::CacheTriangulation( PROGRESS_REPORTER* aReporter, const std::vector<
returns.emplace_back( tp.submit( cache_zones, zone ) );
// Finalize the triangulation threads
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
if( aReporter )
aReporter->KeepRefreshing();
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
}

View File

@ -262,18 +262,18 @@ void CN_CONNECTIVITY_ALGO::searchConnections()
for( size_t ii = 0; ii < dirtyItems.size(); ++ii )
returns[ii] = tp.submit( conn_lambda, ii, &m_itemList, m_progressReporter );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
// Here we balance returns with a 250ms timeout to allow UI updating
std::future_status status;
do
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
while( status != std::future_status::ready )
{
if( m_progressReporter )
m_progressReporter->KeepRefreshing();
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
if( m_progressReporter )
@ -482,18 +482,17 @@ void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
for( size_t ii = 0; ii < zitems.size(); ++ii )
returns[ii] = tp.submit( cache_zones, zitems[ii] );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
if( aReporter )
aReporter->KeepRefreshing();
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}

View File

@ -189,14 +189,14 @@ bool DRC_CACHE_GENERATOR::Run()
for( ZONE* zone : allZones )
returns.emplace_back( tp.submit( cache_zones, zone ) );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / allZones.size() );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}

View File

@ -826,16 +826,15 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
returns.emplace_back( tp.submit( build_netlayer_polys, netLayer.Netcode, netLayer.Layer ) );
}
for( std::future<size_t>& retval : returns )
for( std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
returns.clear();
@ -847,16 +846,15 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
returns.emplace_back( tp.submit( min_checker, itemsPoly, netLayer.Layer, minWidth ) );
}
for( std::future<size_t>& retval : returns )
for( std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
return true;

View File

@ -170,16 +170,15 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
for( const std::pair<ZONE*, ZONE*>& areaZonePair : toCache )
returns.emplace_back( tp.submit( query_areas, areaZonePair ) );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / toCache.size() );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
if( m_drcEngine->IsCancelled() )

View File

@ -176,17 +176,16 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run()
for( size_t ii = 0; ii < copperLayers.size(); ++ii )
returns.emplace_back( tp.submit( sliver_checker, ii ) );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( zoneLayerCount ) / done );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}

View File

@ -231,16 +231,15 @@ bool DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run()
zonelayer.first, zonelayer.second ) );
}
for( const std::future<int>& retval : returns )
for( const std::future<int>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
return !m_drcEngine->IsCancelled();

View File

@ -191,18 +191,17 @@ void FOOTPRINT_LIST_IMPL::loadLibs()
for( size_t ii = 0; ii < num_returns; ++ii )
returns[ii] = tp.submit( loader_job );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
if( m_progress_reporter && !m_progress_reporter->KeepRefreshing() )
m_cancelled = true;
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
}
@ -258,18 +257,17 @@ void FOOTPRINT_LIST_IMPL::loadFootprints()
for( size_t ii = 0; ii < num_elements; ++ii )
returns[ii] = tp.submit( fp_thread );
for( const std::future<size_t>& retval : returns )
for( const std::future<size_t>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
if( m_progress_reporter )
m_progress_reporter->KeepRefreshing();
status = retval.wait_for( std::chrono::milliseconds( 250 ) );
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
std::unique_ptr<FOOTPRINT_INFO> fpi;

View File

@ -270,16 +270,16 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
for( const std::future<int>& ret : returns )
{
std::future_status status;
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
do
while( status != std::future_status::ready )
{
if( m_progressReporter )
m_progressReporter->KeepRefreshing();
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
}
while( status != std::future_status::ready );
}
alg::delete_if( toFill, [&]( const std::pair<ZONE*, PCB_LAYER_ID> pair ) -> bool