diff --git a/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.cpp index 285235b76e397952301c23d8218abb11f1f7aeaf..47f361a428a90f841ef955f68b76dc3ab5a6bed7 100644 --- a/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.cpp @@ -8,6 +8,14 @@ namespace armarx::armem::wm { + CoreSegment::CoreSegment(const CoreSegment& other) : + CoreSegment::Base(other), + _mutex() + { + // Do not copy _mutex. + } + + Commit CoreSegment::toCommit() const { Commit c; @@ -18,6 +26,7 @@ namespace armarx::armem::wm return c; } + void CoreSegment::_copySelfWithoutData(CoreSegment& other) const { other.id() = _id; @@ -27,4 +36,11 @@ namespace armarx::armem::wm other.addProviderSegment(s.copyWithoutData()); } } + + + std::mutex& CoreSegment::mutex() const + { + return _mutex; + } + } diff --git a/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h b/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h index 7847bbb71cc6a1a269556aeec07738c396e42a68..ef4d5f36dce8eaea1301abeb6af8971603481b48 100644 --- a/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h +++ b/source/RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h @@ -1,5 +1,7 @@ #pragma once +#include <mutex> + #include "../base/CoreSegmentBase.h" #include "ProviderSegment.h" @@ -22,7 +24,7 @@ namespace armarx::armem::wm using Base::CoreSegmentBase; - CoreSegment(const CoreSegment& other) = default; + CoreSegment(const CoreSegment& other); CoreSegment(CoreSegment&& other) = default; CoreSegment& operator=(const CoreSegment& other) = default; CoreSegment& operator=(CoreSegment&& other) = default; @@ -33,10 +35,15 @@ namespace armarx::armem::wm */ Commit toCommit() const; + std::mutex& mutex() const; + + protected: virtual void _copySelfWithoutData(CoreSegment& other) const override; + mutable std::mutex _mutex; + }; }