Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.h @ 996:cf52f3bcb2b3 lua-scripting
clarification of Lua classes wrt multithreading
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Jul 2014 16:27:16 +0200 |
parents | 394a19d44f9d |
children | 4136fab6a639 |
comparison
equal
deleted
inserted
replaced
995:8c67382f44a7 | 996:cf52f3bcb2b3 |
---|---|
63 } | 63 } |
64 | 64 |
65 virtual IDynamicObject* Provide(const std::string& id); | 65 virtual IDynamicObject* Provide(const std::string& id); |
66 }; | 66 }; |
67 | 67 |
68 bool ApplyReceivedInstanceFilter(const Json::Value& dicomJson, | |
69 const std::string& remoteAet); | |
70 | |
68 FileStorage storage_; | 71 FileStorage storage_; |
69 ServerIndex index_; | 72 ServerIndex index_; |
70 CompressedFileStorageAccessor accessor_; | 73 CompressedFileStorageAccessor accessor_; |
71 bool compressionEnabled_; | 74 bool compressionEnabled_; |
72 | 75 |
74 boost::mutex dicomCacheMutex_; | 77 boost::mutex dicomCacheMutex_; |
75 MemoryCache dicomCache_; | 78 MemoryCache dicomCache_; |
76 ReusableDicomUserConnection scu_; | 79 ReusableDicomUserConnection scu_; |
77 ServerScheduler scheduler_; | 80 ServerScheduler scheduler_; |
78 | 81 |
82 boost::mutex luaMutex_; | |
79 LuaContext lua_; | 83 LuaContext lua_; |
80 | 84 |
81 public: | 85 public: |
82 class DicomCacheLocker | 86 class DicomCacheLocker : public boost::noncopyable |
83 { | 87 { |
84 private: | 88 private: |
85 ServerContext& that_; | 89 ServerContext& that_; |
86 ParsedDicomFile *dicom_; | 90 ParsedDicomFile *dicom_; |
87 | 91 |
92 ~DicomCacheLocker(); | 96 ~DicomCacheLocker(); |
93 | 97 |
94 ParsedDicomFile& GetDicom() | 98 ParsedDicomFile& GetDicom() |
95 { | 99 { |
96 return *dicom_; | 100 return *dicom_; |
101 } | |
102 }; | |
103 | |
104 class LuaContextLocker : public boost::noncopyable | |
105 { | |
106 private: | |
107 ServerContext& that_; | |
108 | |
109 public: | |
110 LuaContextLocker(ServerContext& that) : that_(that) | |
111 { | |
112 that.luaMutex_.lock(); | |
113 } | |
114 | |
115 ~LuaContextLocker() | |
116 { | |
117 that_.luaMutex_.unlock(); | |
118 } | |
119 | |
120 LuaContext& GetLua() | |
121 { | |
122 return that_.lua_; | |
97 } | 123 } |
98 }; | 124 }; |
99 | 125 |
100 ServerContext(const boost::filesystem::path& storagePath, | 126 ServerContext(const boost::filesystem::path& storagePath, |
101 const boost::filesystem::path& indexPath); | 127 const boost::filesystem::path& indexPath); |
151 void ReadFile(std::string& result, | 177 void ReadFile(std::string& result, |
152 const std::string& instancePublicId, | 178 const std::string& instancePublicId, |
153 FileContentType content, | 179 FileContentType content, |
154 bool uncompressIfNeeded = true); | 180 bool uncompressIfNeeded = true); |
155 | 181 |
156 LuaContext& GetLuaContext() | |
157 { | |
158 return lua_; | |
159 } | |
160 | |
161 void SetStoreMD5ForAttachments(bool storeMD5); | 182 void SetStoreMD5ForAttachments(bool storeMD5); |
162 | 183 |
163 bool IsStoreMD5ForAttachments() const | 184 bool IsStoreMD5ForAttachments() const |
164 { | 185 { |
165 return accessor_.IsStoreMD5(); | 186 return accessor_.IsStoreMD5(); |