Isolate thread pool loops

Now that we are threading things in different frames, we need to watch
that we are not waiting for a process to complete in one frame while
working in another.  To accomplish this, we only wait for our own loop
results

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20572
This commit is contained in:
Seth Hillbrand
2025-04-07 12:17:11 -07:00
parent f0ebf0a7cc
commit bccf365380
4 changed files with 61 additions and 59 deletions
+28 -28
View File
@@ -1398,13 +1398,13 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
thread_pool& tp = GetKiCadThreadPool();
tp.push_loop( connection_vec.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
update_lambda( connection_vec[ii] );
});
tp.wait_for_tasks();
auto results = tp.parallelize_loop( connection_vec.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
update_lambda( connection_vec[ii] );
});
results.wait();
}
}
@@ -1555,13 +1555,13 @@ void CONNECTION_GRAPH::resolveAllDrivers()
thread_pool& tp = GetKiCadThreadPool();
tp.push_loop( dirty_graphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
update_lambda( dirty_graphs[ii] );
});
tp.wait_for_tasks();
auto results = tp.parallelize_loop( dirty_graphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
update_lambda( dirty_graphs[ii] );
});
results.wait();
// Now discard any non-driven subgraphs from further consideration
@@ -2208,14 +2208,14 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
thread_pool& tp = GetKiCadThreadPool();
tp.push_loop( m_driver_subgraphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
m_driver_subgraphs[ii]->UpdateItemConnections();
});
auto results = tp.parallelize_loop( m_driver_subgraphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
m_driver_subgraphs[ii]->UpdateItemConnections();
});
tp.wait_for_tasks();
results.wait();
// Next time through the subgraphs, we do some post-processing to handle things like
// connecting bus members to their neighboring subgraphs, and then propagate connections
@@ -2414,13 +2414,13 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* a
return 1;
};
tp.push_loop( m_driver_subgraphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
updateItemConnectionsTask( m_driver_subgraphs[ii] );
});
tp.wait_for_tasks();
auto results2 = tp.parallelize_loop( m_driver_subgraphs.size(),
[&]( const int a, const int b)
{
for( int ii = a; ii < b; ++ii )
updateItemConnectionsTask( m_driver_subgraphs[ii] );
});
results2.wait();
m_net_code_to_subgraphs_map.clear();
m_net_name_to_subgraphs_map.clear();