From db46e5bb58ed12dbff38ceea402140cfa57b32cc Mon Sep 17 00:00:00 2001 From: Carmen Fan Date: Tue, 26 Apr 2022 15:18:38 +0100 Subject: [PATCH] ISSUE #571 default to 4 threads, make num threads configurable through ENV var --- ifcUtils/repo_ifc_utils_geometry_handler.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ifcUtils/repo_ifc_utils_geometry_handler.cpp b/ifcUtils/repo_ifc_utils_geometry_handler.cpp index 4278447bd..c4e7e98e3 100644 --- a/ifcUtils/repo_ifc_utils_geometry_handler.cpp +++ b/ifcUtils/repo_ifc_utils_geometry_handler.cpp @@ -104,7 +104,23 @@ bool repo::ifcUtility::SCHEMA_NS::GeometryHandler::retrieveGeometry( IfcParse::IfcFile ifcfile(file); auto itSettings = createSettings(); - IfcGeom::Iterator contextIterator(itSettings, &ifcfile); + char* value = getenv("REPO_NUM_THREADS"); + + int nThreads = 0; + try { + if (value && strlen(value) > 0) { + nThreads = std::stoi(value); + } + } + catch (...) { + //do nothing. + } + + nThreads = nThreads ? nThreads : 4; + + repoInfo << "Initialising Geom iterator with " << nThreads << "..."; + + IfcGeom::Iterator contextIterator(itSettings, &ifcfile, nThreads); try { if (!contextIterator.initialize()) {