IndexerThreadPool: IndexerThreadPool return value, not promise + if no spots or no indexing algorithm, don't queue

This commit is contained in:
2026-04-16 19:40:27 +02:00
parent 7899765e5f
commit 5a830d7af6
4 changed files with 15 additions and 7 deletions
+10 -4
View File
@@ -14,7 +14,9 @@
#endif
IndexerThreadPool::IndexerThreadPool(const IndexingSettings &settings, const NUMAHWPolicy &numa_policy)
: stop(false), workers_ready(settings.GetIndexingThreads()) {
: workers_ready(settings.GetIndexingThreads()),
viable_cell_min_spots(settings.GetViableCellMinSpots()),
stop(false) {
for (size_t i = 0; i < settings.GetIndexingThreads(); ++i)
workers.emplace_back([this, i, numa_policy, settings] { Worker(i, numa_policy, settings); });
workers_ready.wait();
@@ -47,8 +49,12 @@ IndexerThreadPool::~IndexerThreadPool() { {
}
}
std::future<IndexerResult> IndexerThreadPool::Run(const DiffractionExperiment &experiment,
const std::vector<Coord>& recip) {
IndexerResult IndexerThreadPool::Run(const DiffractionExperiment &experiment, const std::vector<Coord> &recip) {
if (experiment.GetIndexingAlgorithm() == IndexingAlgorithmEnum::None)
return IndexerResult{.lattice = {}, .indexing_time_s = 0};
if (recip.size() < viable_cell_min_spots)
return IndexerResult{.lattice = {}, .indexing_time_s = 0};
// Create a promise/future pair
auto promise = std::make_shared<std::promise<IndexerResult > >();
std::future<IndexerResult> result = promise->get_future(); {
@@ -64,7 +70,7 @@ std::future<IndexerResult> IndexerThreadPool::Run(const DiffractionExperiment &e
}
cond.notify_one();
return result;
return result.get();
}
void IndexerThreadPool::Worker(int32_t threadIndex, const NUMAHWPolicy &numa_policy, const IndexingSettings &settings) {