diff OrthancServer/ServerContext.h @ 778:aebf0071020e

refactoring of the mutex for the dicom cache
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 May 2014 11:02:23 +0200
parents 537837f50fbb
children 331eaf9d9d69
line wrap: on
line diff
--- a/OrthancServer/ServerContext.h	Wed Apr 30 17:53:01 2014 +0200
+++ b/OrthancServer/ServerContext.h	Fri May 02 11:02:23 2014 +0200
@@ -70,12 +70,31 @@
     bool compressionEnabled_;
     
     DicomCacheProvider provider_;
+    boost::mutex dicomCacheMutex_;
     MemoryCache dicomCache_;
     ReusableDicomUserConnection scu_;
 
     LuaContext lua_;
 
   public:
+    class DicomCacheLocker
+    {
+    private:
+      ServerContext& that_;
+      ParsedDicomFile *dicom_;
+
+    public:
+      DicomCacheLocker(ServerContext& that,
+                       const std::string& instancePublicId);
+
+      ~DicomCacheLocker();
+
+      ParsedDicomFile& GetDicom()
+      {
+        return *dicom_;
+      }
+    };
+
     ServerContext(const boost::filesystem::path& storagePath,
                   const boost::filesystem::path& indexPath);
 
@@ -138,9 +157,6 @@
                   FileContentType content,
                   bool uncompressIfNeeded = true);
 
-    // TODO IMPLEMENT MULTITHREADING FOR THIS METHOD
-    ParsedDicomFile& GetDicomFile(const std::string& instancePublicId);
-
     LuaContext& GetLuaContext()
     {
       return lua_;