diff OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 5130:f2dcdbe05884

ResourceModification jobs can now use multiple threads
author Alain Mazy <am@osimis.io>
date Thu, 05 Jan 2023 17:24:43 +0100
parents 8638522eeda1
children 482f3e80ed0a
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Dec 19 20:00:21 2022 +0100
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Thu Jan 05 17:24:43 2023 +0100
@@ -439,6 +439,8 @@
                                                         const std::string& mapped,
                                                         ResourceType level)
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, original));
 
     if (previous == uidMap_.end())
@@ -450,6 +452,8 @@
   std::string DicomModification::MapDicomIdentifier(const std::string& original,
                                                     ResourceType level)
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     const std::string stripped = Toolbox::StripSpaces(original);
     
     std::string mapped;
@@ -684,6 +688,8 @@
 
   void DicomModification::SetLevel(ResourceType level)
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     uidMap_.clear();
     level_ = level;
 
@@ -839,6 +845,8 @@
 
   void DicomModification::SetupAnonymization(DicomVersion version)
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     isAnonymization_ = true;
     
     removals_.clear();
@@ -1423,6 +1431,8 @@
   
   void DicomModification::Serialize(Json::Value& value) const
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     if (identifierGenerator_ != NULL)
     {
       throw OrthancException(ErrorCode_InternalError,
@@ -1548,6 +1558,8 @@
                                             const Json::Value& serialized,
                                             const char* field)
   {
+    boost::recursive_mutex::scoped_lock lock(uidMapMutex_);
+
     if (!serialized.isMember(field) ||
         serialized[field].type() != Json::objectValue)
     {