Mercurial > hg > orthanc
diff OrthancServer/ServerContext.cpp @ 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 | 4e3593c3511d |
children | 381f90e2b69d |
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp Wed Apr 30 17:53:01 2014 +0200 +++ b/OrthancServer/ServerContext.cpp Fri May 02 11:02:23 2014 +0200 @@ -222,14 +222,26 @@ } - ParsedDicomFile& ServerContext::GetDicomFile(const std::string& instancePublicId) + ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that, + const std::string& instancePublicId) : + that_(that) { #if ENABLE_DICOM_CACHE == 0 static std::auto_ptr<IDynamicObject> p; p.reset(provider_.Provide(instancePublicId)); - return dynamic_cast<ParsedDicomFile&>(*p); + dicom_ = dynamic_cast<ParsedDicomFile*>(p.get()); #else - return dynamic_cast<ParsedDicomFile&>(dicomCache_.Access(instancePublicId)); + that_.dicomCacheMutex_.lock(); + dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId)); +#endif + } + + + ServerContext::DicomCacheLocker::~DicomCacheLocker() + { +#if ENABLE_DICOM_CACHE == 0 +#else + that_.dicomCacheMutex_.unlock(); #endif }