From 72206bc4411277e79bae690054721ce301ba3275 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 11 Nov 2021 12:05:47 +0100 Subject: [PATCH] async init, crashes now on get() --- src/ifcgeom/IfcGeomIteratorImplementation.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index ec1ec5a9c6..00ec057b27 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -184,6 +184,9 @@ namespace IfcGeom { boost::optional initialization_outcome_; + // Should not be destructed because, destructor is blocking + std::future init_future_; + bool initialize() { if (initialization_outcome_) { return *initialization_outcome_; @@ -233,9 +236,10 @@ namespace IfcGeom { if (num_threads_ != 1) { collect(); - process_concurrently(); - initialization_outcome_ = !all_processed_elements_.empty(); + initialization_outcome_ = !tasks_.empty(); + + init_future_ = std::async(std::launch::async, [this]() { process_concurrently(); }); } else { initialization_outcome_ = create(); } @@ -338,10 +342,10 @@ namespace IfcGeom { fu.get(); processed += 1; - progress_ = processed * 50 / tasks_.size(); - if (progress_ != old_progress) { - Logger::ProgressBar(progress_); - old_progress = progress_; + progress_ = processed * 100 / tasks_.size(); + if (progress_ / 2 != old_progress) { + Logger::ProgressBar(progress_ / 2); + old_progress = progress_ / 2; } }