mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Wait for threads in iterator destructor
This commit is contained in:
@@ -102,6 +102,7 @@ namespace IfcGeom {
|
|||||||
GeometrySerializer* cache_ = nullptr;
|
GeometrySerializer* cache_ = nullptr;
|
||||||
|
|
||||||
std::atomic<bool> finished_{ false };
|
std::atomic<bool> finished_{ false };
|
||||||
|
std::atomic<bool> terminating_{ false };
|
||||||
std::atomic<int> progress_{ 0 };
|
std::atomic<int> progress_{ 0 };
|
||||||
|
|
||||||
std::vector<geometry_conversion_result> tasks_;
|
std::vector<geometry_conversion_result> tasks_;
|
||||||
@@ -316,6 +317,10 @@ namespace IfcGeom {
|
|||||||
std::ref(settings_),
|
std::ref(settings_),
|
||||||
&rep);
|
&rep);
|
||||||
|
|
||||||
|
if (terminating_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
threadpool.emplace_back(std::move(fu));
|
threadpool.emplace_back(std::move(fu));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,9 +332,11 @@ namespace IfcGeom {
|
|||||||
|
|
||||||
Logger::SetProduct(boost::none);
|
Logger::SetProduct(boost::none);
|
||||||
|
|
||||||
|
if (!terminating_) {
|
||||||
Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
|
Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
|
||||||
" objects) ");
|
" objects) ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Computes model's bounding box (bounds_min and bounds_max).
|
/// Computes model's bounding box (bounds_min and bounds_max).
|
||||||
/// @note Can take several minutes for large files.
|
/// @note Can take several minutes for large files.
|
||||||
@@ -773,6 +780,14 @@ namespace IfcGeom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Iterator() {
|
~Iterator() {
|
||||||
|
if (num_threads_ != 1) {
|
||||||
|
terminating_ = true;
|
||||||
|
|
||||||
|
if (init_future_.valid()) {
|
||||||
|
init_future_.wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (owns_ifc_file) {
|
if (owns_ifc_file) {
|
||||||
delete ifc_file;
|
delete ifc_file;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user