Skip to content
Snippets Groups Projects
Commit 9fdc2b62 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Lock core segment mutex in Memory::update()

parent 122302a6
No related branches found
No related tags found
No related merge requests found
......@@ -238,7 +238,7 @@ namespace armarx::armem::base
* @param update The update.
* @return The resulting entity snapshot's ID.
*/
UpdateResult update(const EntityUpdate& update)
virtual UpdateResult update(const EntityUpdate& update)
{
this->_checkContainerName(update.entityID.memoryName, this->name());
......
......@@ -3,6 +3,28 @@
namespace armarx::armem::wm
{
Memory::Base::UpdateResult Memory::update(const EntityUpdate& update)
{
this->_checkContainerName(update.entityID.memoryName, this->name());
auto it = this->_container.find(update.entityID.coreSegmentName);
if (it != this->_container.end())
{
Base::UpdateResult ret;
{
std::scoped_lock lock(it->second.mutex());
ret = it->second.update(update);
}
ret.memoryUpdateType = UpdateType::UpdatedExisting;
return ret;
}
else
{
throw armem::error::MissingEntry::create<CoreSegment>(update.entityID.coreSegmentName, *this);
}
}
Commit Memory::toCommit() const
{
Commit c;
......
......@@ -27,6 +27,10 @@ namespace armarx::armem::wm
Memory& operator=(const Memory& other) = default;
Memory& operator=(Memory&& other) = default;
virtual Base::UpdateResult update(const EntityUpdate& update) override;
/**
* @brief Convert the content of this memory into a commit
* @return The resulting commit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment