mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Don't use cached items in multi-threaded mode for now until we have proper immutability
This commit is contained in:
@@ -171,6 +171,10 @@ namespace IfcGeom {
|
|||||||
|
|
||||||
converter_ = new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_);
|
converter_ = new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_);
|
||||||
std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
|
std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
|
||||||
|
if (num_threads_ != 1) {
|
||||||
|
// @todo this shouldn't be necessary with properly immutable taxonomy items
|
||||||
|
converter_->mapping()->use_caching() = false;
|
||||||
|
}
|
||||||
converter_->mapping()->get_representations(reps, filters_);
|
converter_->mapping()->get_representations(reps, filters_);
|
||||||
|
|
||||||
for (auto& task : reps) {
|
for (auto& task : reps) {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace geometry {
|
|||||||
class abstract_mapping {
|
class abstract_mapping {
|
||||||
protected:
|
protected:
|
||||||
Settings settings_;
|
Settings settings_;
|
||||||
|
|
||||||
|
bool use_caching_ = true;
|
||||||
public:
|
public:
|
||||||
abstract_mapping(Settings& s) : settings_(s) {}
|
abstract_mapping(Settings& s) : settings_(s) {}
|
||||||
|
|
||||||
@@ -45,6 +47,9 @@ namespace geometry {
|
|||||||
|
|
||||||
const Settings& settings() const { return settings_; }
|
const Settings& settings() const { return settings_; }
|
||||||
Settings& settings() { return settings_; }
|
Settings& settings() { return settings_; }
|
||||||
|
|
||||||
|
bool use_caching() const { return use_caching_; }
|
||||||
|
bool& use_caching() { return use_caching_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|||||||
@@ -520,9 +520,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
|||||||
|
|
||||||
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
||||||
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
|
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
|
||||||
auto it = cache_.find(iden);
|
if (use_caching_) {
|
||||||
if (it != cache_.end()) {
|
auto it = cache_.find(iden);
|
||||||
return it->second;
|
if (it != cache_.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taxonomy::ptr item = nullptr;
|
taxonomy::ptr item = nullptr;
|
||||||
|
|
||||||
@@ -532,7 +534,7 @@ taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
|||||||
|
|
||||||
#include "bind_convert_impl.i"
|
#include "bind_convert_impl.i"
|
||||||
|
|
||||||
if (item) {
|
if (use_caching_ && item) {
|
||||||
cache_.insert({ iden, item });
|
cache_.insert({ iden, item });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user