Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20260723.0
1.20260723.1
46 changes: 1 addition & 45 deletions src/support/cellml/cellmlfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,8 @@ limitations under the License.
#include "libopencor/solvercvode.h"
#include "libopencor/solverkinsol.h"

#include <mutex>
#include <unordered_map>

namespace libOpenCOR {

namespace {

// Cache of compiled runtimes, keyed by CellmlFile pointer.

std::mutex sRuntimesMutex; // NOLINT
std::unordered_map<const CellmlFile *, CellmlFileRuntimePtr> sRuntimes; // NOLINT

} // namespace

CellmlFile::Impl::Impl(const FilePtr &pFile, const libcellml::ModelPtr &pModel, bool pStrict)
: mFile(pFile)
, mModel(pModel)
Expand Down Expand Up @@ -128,46 +116,14 @@ libcellml::AnalyserModelPtr CellmlFile::Impl::analyserModel() const

CellmlFileRuntimePtr CellmlFile::Impl::runtime(const CellmlFilePtr &pCellmlFile, const SolverNlaPtr &pNlaSolver)
{
// Check whether we already have a compiled runtime and if so then return it.

{
const std::scoped_lock<std::mutex> lock(sRuntimesMutex);
const auto it = sRuntimes.find(pCellmlFile.get());

if (it != sRuntimes.end()) {
return it->second;
}
}

// There is no compiled runtime for this CellML file, so create one, track it, and return it.

auto runtime = CellmlFileRuntime::create(pCellmlFile, pNlaSolver);

{
const std::scoped_lock<std::mutex> lock(sRuntimesMutex);

sRuntimes.try_emplace(pCellmlFile.get(), runtime);
}

return runtime;
return CellmlFileRuntime::create(pCellmlFile, pNlaSolver);
}
Comment thread
agarny marked this conversation as resolved.
Comment thread
agarny marked this conversation as resolved.

CellmlFile::CellmlFile(const FilePtr &pFile, const libcellml::ModelPtr &pModel, bool pStrict)
: Logger(std::make_unique<Impl>(pFile, pModel, pStrict))
{
}

CellmlFile::~CellmlFile()
{
// Stop tracking our compiled runtime.

{
const std::scoped_lock<std::mutex> lock(sRuntimesMutex);

sRuntimes.erase(this);
}
}

CellmlFile::Impl *CellmlFile::pimpl()
{
return static_cast<Impl *>(Logger::mPimpl.get());
Expand Down
1 change: 0 additions & 1 deletion src/support/cellml/cellmlfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LIBOPENCOR_UNIT_TESTING_EXPORT CellmlFile: public Logger
{
public:
CellmlFile() = delete;
~CellmlFile() override;

CellmlFile(const CellmlFile &pOther) = delete;
CellmlFile(CellmlFile &&pOther) noexcept = delete;
Expand Down
Loading